demos for spacedust

all non-secret accounts

+26 -5
+3 -2
atproto-notifications/src/pages/Admin.tsx
··· 84 84 credentials 85 85 ok={secrets => secrets.map(s => <Secret key={s.password} {...s} />)} 86 86 /> 87 + <Secret password={null} added={0} expired={null} /> 87 88 </> 88 89 ); 89 90 } ··· 94 95 return ( 95 96 <div className="admin-secret"> 96 97 <p className="admin-secret-secret"> 97 - "{password}" 98 + {password !== null ? <>"{password}"</> : '[no password]'} 98 99 {' '} 99 100 (added <ReactTimeAgo date={new Date(added)} locale="en-US" /> 100 101 {expired && ( ··· 123 124 </p> 124 125 <GetJson 125 126 endpoint="/top-secret-accounts" 126 - params={{ secret_password: password }} 127 + params={{ secret_password: password ?? '' }} 127 128 credentials 128 129 ok={accounts => accounts.length > 0 ? ( 129 130 <ul>
+2 -1
server/api.js
··· 202 202 }; 203 203 204 204 const handleTopSecretAccounts = async (db, req, res, searchParams) => { 205 - const accounts = db.getSecretAccounts(searchParams.get('secret_password')); 205 + const secret = searchParams.get('secret_password'); 206 + const accounts = secret ? db.getSecretAccounts(secret) : db.getNonSecretAccounts(); 206 207 return ok(res, accounts); 207 208 }; 208 209
+21 -2
server/db.js
··· 20 20 #stmt_admin_expire_secret; 21 21 #stmt_admin_get_secrets; 22 22 #stmt_admin_secret_accounts; 23 + #stmt_admin_nonsecret_accounts; 23 24 24 25 #transactionally; 25 26 #db; ··· 137 138 unixepoch(max(p.last_push)) * 1000 as 'last_push' 138 139 from accounts 139 140 left outer join push_subs p on (p.account_did = did) 140 - where secret_password = ? 141 + where secret_password = :password 142 + group by did 143 + order by first_seen desc`); 144 + 145 + this.#stmt_admin_nonsecret_accounts = db.prepare( 146 + `select did, 147 + unixepoch(first_seen) * 1000 as 'first_seen', 148 + role, 149 + count(*) as 'active_subs', 150 + sum(p.total_pushes) as 'total_pushes', 151 + unixepoch(max(p.last_push)) * 1000 as 'last_push' 152 + from accounts 153 + left outer join push_subs p on (p.account_did = did) 154 + left outer join top_secret_passwords s on (s.password = secret_password) 155 + where s.password is null 141 156 group by did 142 157 order by first_seen desc`); 143 158 ··· 204 219 } 205 220 206 221 getSecretAccounts(secretPassword) { 207 - return this.#stmt_admin_secret_accounts.all(secretPassword); 222 + return this.#stmt_admin_secret_accounts.all({ password: secretPassword }); 223 + } 224 + 225 + getNonSecretAccounts() { 226 + return this.#stmt_admin_nonsecret_accounts.all(); 208 227 } 209 228 }