From 0817196b9f3d1ac75ecbed686c7653bb4f5ecc63 Mon Sep 17 00:00:00 2001 From: phil Date: Thu, 10 Jul 2025 16:59:36 -0400 Subject: [PATCH] admin-only access --- atproto-notifications/src/App.tsx | 27 ++++++++++++++++++++------- server/db.js | 7 +++++-- server/index.js | 21 +++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/atproto-notifications/src/App.tsx b/atproto-notifications/src/App.tsx index 3e4faa6..73f5fef 100644 --- a/atproto-notifications/src/App.tsx +++ b/atproto-notifications/src/App.tsx @@ -14,7 +14,7 @@ const Problem = ({ children }) => ( ); -function requestPermission(host, setAsking) { +function requestPermission(host, setAsking, setPermissionError) { return async () => { setAsking(true); let err; @@ -27,8 +27,17 @@ function requestPermission(host, setAsking) { body: JSON.stringify({ sub }), credentials: 'include', }); - if (!res.ok) throw res; + if (!res.ok) { + let content; + try { + content = (await res.json()).reason; + } catch (_) { + content = await res.text(); + } + throw content; + } } catch (e) { + setPermissionError(e); err = e; } setAsking(false); @@ -68,6 +77,7 @@ function App() { const [user, setUser] = useLocalStorage('spacedust-notif-user', null); const [verif, setVerif] = useState(null); const [asking, setAsking] = useState(false); + const [permissionError, setPermissionError] = useState(null); const onIdentify = useCallback(async details => { setVerif('verifying'); @@ -102,14 +112,14 @@ function App() { content = <>

Sorry, failed to verify that identity. please let us know!

{content}; } } - } else if (notifPerm !== 'granted') { + } else if (permissionError !== null || notifPerm !== 'granted') { content = ( <>

Step 2: Allow notifications

To show notifications we need permission: