source: Klonkt/test/c2s-reply-visibility.test.js@ 1d5ffc0

main
Last change on this file since 1d5ffc0 was de89079, checked in by Robin Genis <roboburr@…>, 6 weeks ago

C2S: liked/boosted op de inbox-read + followers-only reply-adressering

Voor de Shaer-detailweergave (Like/Boost/Reply): de inbox-read serveert nu per
note shaer:liked/shaer:boosted (uit ap_timeline.liked/boosted), zodat de app de
knop-status toont en kan togglen/undoen. En een reply kan followers-only: als de
client de reply als .friends stuurt, respecteert de outbox dat nu (de auteur in
to + onze volgers in cc, GEEN Public). De standaard-reply blijft quiet-public.

hasGuardians blijft ongewijzigd automatisch gestempeld (keuze Robin).

Changed files:
src/routes/activitypub.js

  • inbox-read: shaer:liked + shaer:boosted per note

src/services/ActivityPubService.js

  • buildNote(isReply): visibility 'friends' -> cc zonder Public (followers-only)
  • deliverReply accepteert visibility en bewaart 'friends' op de ap_outbox-rij
  • ingestOutboxActivity geeft c2sVisibility(object) door aan de reply

New file:
test/c2s-reply-visibility.test.js

  • followers-only reply (auteur+followers, geen Public), quiet-public default, direct-note

remarks: 190 tests groen (was 187).

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

  • Property mode set to 100644
File size: 1.8 KB
Line 
1// A Shaer detail-view Reply is followers-only: buildNote(isReply) with
2// visibility 'friends' addresses the parent author + followers, but NOT Public.
3import { test } from 'node:test';
4import assert from 'node:assert/strict';
5process.env.DATABASE_PATH = ':memory:';
6process.env.PUBLIC_BASE_URL = 'https://test.example';
7const dbMod = await import('../src/config/database.js');
8dbMod.initializeDatabase();
9const { buildNote } = await import('../src/services/ActivityPubService.js');
10
11const PUBLIC = 'https://www.w3.org/ns/activitystreams#Public';
12const base = 'https://test.example';
13const site = { slug: 'kid' };
14const row = (visibility) => ({
15 id: 'reply-1', in_reply_to: 'https://mastodon.social/@alice/1',
16 content: '<p>hi</p>', to_actor: 'https://mastodon.social/users/alice', visibility,
17});
18
19test('followers-only reply: author in to, followers in cc, NO Public', () => {
20 const note = buildNote(base, site, row('friends'), { isReply: true });
21 assert.deepEqual(note.to, ['https://mastodon.social/users/alice']);
22 assert.deepEqual(note.cc, [`${base}/ap/users/kid/followers`]);
23 assert.ok(!note.cc.includes(PUBLIC));
24 assert.equal(note.inReplyTo, 'https://mastodon.social/@alice/1');
25});
26
27test('default reply stays quiet-public: author in to, Public + followers in cc', () => {
28 const note = buildNote(base, site, row(null), { isReply: true });
29 assert.deepEqual(note.to, ['https://mastodon.social/users/alice']);
30 assert.ok(note.cc.includes(PUBLIC));
31 assert.ok(note.cc.includes(`${base}/ap/users/kid/followers`));
32});
33
34test('direct note addresses only its recipients (no Public/followers)', () => {
35 const note = buildNote(base, site, {
36 id: 'dm-1', content: '<p>x</p>', visibility: 'direct',
37 to_actors: JSON.stringify(['https://s/u/bob']),
38 }, { isReply: true });
39 assert.deepEqual(note.to, ['https://s/u/bob']);
40 assert.deepEqual(note.cc, []);
41});
Note: See TracBrowser for help on using the repository browser.