WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(appview): include uri in GET /api/admin/roles response (ATB-43)

Add rkey and did fields to the roles DB query, then construct the AT URI
(at://<did>/space.atbb.forum.role/<rkey>) in the response map so the
admin members page dropdown can submit a valid roleUri.

Malpercio 0be83919 5f03e3e1

+29
+26
apps/appview/src/routes/__tests__/admin.test.ts
··· 451 451 const data = await res.json(); 452 452 expect(data.roles).toEqual([]); 453 453 }); 454 + 455 + it("includes uri field constructed from did and rkey", async () => { 456 + // Seed a role matching the pattern used in this describe block 457 + await ctx.db.insert(roles).values({ 458 + did: ctx.config.forumDid, 459 + rkey: "moderator", 460 + cid: "bafymoderator", 461 + name: "Moderator", 462 + description: "Moderator", 463 + priority: 20, 464 + createdAt: new Date(), 465 + indexedAt: new Date(), 466 + }); 467 + 468 + const res = await app.request("/api/admin/roles"); 469 + 470 + expect(res.status).toBe(200); 471 + const data = await res.json() as { roles: Array<{ name: string; uri: string; id: string }> }; 472 + expect(data.roles.length).toBeGreaterThan(0); 473 + // Every role should have a uri field 474 + for (const role of data.roles) { 475 + expect(role.uri).toBeDefined(); 476 + expect(role.uri).toMatch(/^at:\/\//); 477 + expect(role.uri).toContain("/space.atbb.forum.role/"); 478 + } 479 + }); 454 480 }); 455 481 456 482 describe.sequential("GET /api/admin/members", () => {
+3
apps/appview/src/routes/admin.ts
··· 163 163 name: roles.name, 164 164 description: roles.description, 165 165 priority: roles.priority, 166 + rkey: roles.rkey, 167 + did: roles.did, 166 168 }) 167 169 .from(roles) 168 170 .where(eq(roles.did, ctx.config.forumDid)) ··· 180 182 description: role.description, 181 183 permissions: perms.map((p) => p.permission), 182 184 priority: role.priority, 185 + uri: `at://${role.did}/space.atbb.forum.role/${role.rkey}`, 183 186 }; 184 187 }) 185 188 );