Merge pull request #2077 from RoboSats/keep-nostr-updated

Keep nostr updated
This commit is contained in:
KoalaSat
2025-07-13 10:17:11 +00:00
committed by GitHub
2 changed files with 14 additions and 9 deletions

View File

@ -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 (
<Box sx={{ flexGrow: 1 }}>
<Bar position='fixed' sx={{ top: 'auto', bottom: 0 }}>

View File

@ -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 created before nostr_pubkey were introduced
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)