Changeset f2796d3 in Klonkt for src/routes
- Timestamp:
- 06/29/2026 10:19:54 PM (2 months ago)
- Branches:
- main
- Children:
- 3f9f71d
- Parents:
- fb6819d
- File:
-
- 1 edited
-
src/routes/activitypub.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
rfb6819d rf2796d3 46 46 res.type('application/jrd+json; charset=utf-8'); 47 47 res.set('Cache-Control', 'public, max-age=300'); 48 const actorUri = AP.actorId(baseUrl(req), site.slug); 49 const profileUrl = baseUrl(req) + (site.slug === primarySlug() ? '/' : `/user/${encodeURIComponent(site.slug)}`); 48 50 res.send(JSON.stringify({ 49 51 subject: `acct:${site.slug}@${hostOf(req)}`, 50 links: [{ rel: 'self', type: 'application/activity+json', href: AP.actorId(baseUrl(req), site.slug) }], 52 aliases: [actorUri, profileUrl], 53 links: [ 54 { rel: 'self', type: 'application/activity+json', href: actorUri }, 55 { rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: profileUrl }, 56 ], 51 57 })); 52 58 }); … … 83 89 const n = db.prepare('SELECT COUNT(*) n FROM ap_followers WHERE slug = ?').get(site.slug).n; 84 90 AP.sendAP(res, AP.buildFollowers(baseUrl(req), site, n)); 91 }); 92 93 // ── Following (count only) ──────────────────────────────────────── 94 router.get('/ap/users/:slug/following', (req, res) => { 95 const site = publicSite(req.params.slug); 96 if (!site) return res.status(404).end(); 97 let n = 0; 98 try { n = db.prepare("SELECT COUNT(*) n FROM ap_following WHERE slug = ? AND status = 'accepted'").get(site.slug).n; } catch { /* table may not exist */ } 99 AP.sendAP(res, AP.buildFollowing(baseUrl(req), site, n)); 85 100 }); 86 101 … … 151 166 router.get('/nodeinfo/2.1', (req, res) => { 152 167 let users = 0; let posts = 0; 153 try { users = db.prepare('SELECT COUNT(*) c FROM users').get().c; } catch { /* */ } 168 // "users" = public AP actors (sites), not the admin/member account rows. 169 try { users = db.prepare('SELECT COUNT(*) c FROM sites WHERE (is_public IS NULL OR is_public = 1)').get().c; } catch { /* */ } 154 170 try { posts = db.prepare("SELECT COUNT(*) c FROM posts WHERE status = 'published'").get().c; } catch { /* */ } 155 171 res.type('application/json; charset=utf-8');
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)