From a60311f55afd2bcf46a3eb8acbfb0a76805e5848 Mon Sep 17 00:00:00 2001 From: koalasat Date: Sun, 13 Jul 2025 12:04:49 +0200 Subject: [PATCH] Keep nostr updated --- frontend/src/basic/NavBar/AppBar/index.tsx | 6 +++++- robosats/middleware.py | 17 +++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/frontend/src/basic/NavBar/AppBar/index.tsx b/frontend/src/basic/NavBar/AppBar/index.tsx index 4d2dcd04..c8d780f9 100644 --- a/frontend/src/basic/NavBar/AppBar/index.tsx +++ b/frontend/src/basic/NavBar/AppBar/index.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useState } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { AppBar as Bar, Toolbar, @@ -65,6 +65,10 @@ const AppBar = ({ changePage }: AppBarProps): React.JSX.Element => { void garage.createRobot(federation, token, Object.keys(garage.slots).length > 0); }; + useEffect(() => { + if (!show) setOpenGarage(false); + }, [show]); + return ( diff --git a/robosats/middleware.py b/robosats/middleware.py index 6a9bf509..19879cf6 100644 --- a/robosats/middleware.py +++ b/robosats/middleware.py @@ -90,14 +90,15 @@ class RobotTokenSHA256AuthenticationMiddleWare: if token.user.last_login < timezone.now() - timedelta(minutes=2): update_last_login(None, token.user) - # START deprecate after v0.6.0 - # Add the hash_id to robots created before hash_ids were introduced - if not token.user.robot.hash_id: - token_sha256 = base91_to_hex(token_sha256_b91) - hash = hashlib.sha256(token_sha256.encode("utf-8")).hexdigest() - token.user.robot.hash_id = hash - token.user.robot.save(update_fields=["hash_id"]) - # END deprecate after v0.6.0 + # START deprecate after v0.8.0 + # Add the nostr_pubkey to robots + nostr_pubkey = request.META.get("NOSTR_PUBKEY", "").replace( + "Nostr ", "" + ) + token.user.robot.nostr_pubkey = nostr_pubkey + + token.user.robot.save(update_fields=["nostr_pubkey"]) + # END deprecate after v0.8.0 except Exception: update_last_login(None, token.user)