source: Klonkt/test/c2s-inbox.test.js@ c7a211d

main
Last change on this file since c7a211d was 0cea12b, checked in by Robin <roboburr@…>, 7 weeks ago

Feature: owner inbox read over C2S (GET, bearer-gated)

GET /ap/users/:slug/inbox with a bearer scoped to that site returns the
recent timeline (accounts the owner follows) as an OrderedCollection of
Create(Note) items with content, url, published, sensitive and summary
(CW). Anyone else gets 403: the inbox stays write-only for the public.
This is the missing read half for a connected app's unified feed
(Shaer HomeBase, bead shaer-n4h); same gate pattern as the owner
followers/following read.

Changed files:
src/routes/activitypub.js

  • GET /ap/users/:slug/inbox (owner only) mapping ap_timeline rows

New file:
test/c2s-inbox.test.js

  • data-path coverage for the fields the mapping relies on

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

  • Property mode set to 100644
File size: 1.2 KB
Line 
1// C2S inbox read (owner only): the route maps ap_timeline rows to Create(Note)
2// items; here we cover the data path (fields the mapping relies on). The
3// bearer gate itself follows the followers-route pattern (verified live).
4import { test } from 'node:test';
5import assert from 'node:assert/strict';
6
7process.env.DATABASE_PATH = ':memory:';
8process.env.PUBLIC_BASE_URL = 'https://klonkt.test';
9
10const dbMod = await import('../src/config/database.js');
11const db = dbMod.default;
12dbMod.initializeDatabase();
13const AP = (await import('../src/services/ActivityPubService.js')).default;
14
15db.prepare(`INSERT INTO ap_timeline (id, slug, author_uri, author_name, content, url, published, nsfw, cw, created_at)
16 VALUES ('https://r.test/n/1','me','https://r.test/u/a','A','<p>hoi</p>','https://r.test/@a/1','2026-07-01T10:00:00Z',1,'let op',CURRENT_TIMESTAMP)`).run();
17
18test('timeline rows carry the fields the inbox mapping needs', () => {
19 const [t] = AP.getTimeline('me', 10);
20 assert.equal(t.id, 'https://r.test/n/1');
21 assert.equal(t.author_uri, 'https://r.test/u/a');
22 assert.equal(t.content, '<p>hoi</p>');
23 assert.equal(t.url, 'https://r.test/@a/1');
24 assert.equal(t.nsfw, 1);
25 assert.equal(t.cw, 'let op');
26 assert.ok(t.published);
27});
Note: See TracBrowser for help on using the repository browser.