Changeset 155c24e in Klonkt for test/c2s-direct.test.js


Ignore:
Timestamp:
07/20/2026 10:52:58 PM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
7922694
Parents:
e6c6e6f
git-author:
Robin <roboburr@…> (07/20/2026 10:52:57 PM)
git-committer:
Robin <roboburr@…> (07/20/2026 10:52:58 PM)
Message:

Feature: emit shaer:helpRequest on direct notes (FEP-633c 5.2.1)

The wire now claims exactly what the FEP specifies. The shaer
namespace (https://ns.klonkt.com/shaer#) joins AP_CONTEXT, so the term
is valid JSON-LD; a C2S note carrying shaer:helpRequest true routes
through the direct path with the flag stored (additive column
ap_outbox.help_request) and the built note emits the term, strictly on
direct notes only. Non-observing servers ignore it; a guardian-side
client can render the alert card the spec allows.

Changed files:
src/services/ActivityPubService.js

  • shaer namespace in AP_CONTEXT
  • ingest reads shaer:helpRequest / helpRequest from the object
  • deliverDirectNote stores the flag; buildReplyNote emits the term

src/config/database.js

  • additive column ap_outbox.help_request

test/c2s-direct.test.js

  • term emitted with flag, absent without, namespace declared

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/c2s-direct.test.js

    re6c6e6f r155c24e  
    3838});
    3939
     40test('a help request emits shaer:helpRequest (FEP-633c 5.2.1)', () => {
     41  db.prepare(`INSERT INTO ap_outbox (id, site_slug, post_id, post_slug, in_reply_to, to_actor, to_handle, content, visibility, to_actors, help_request, created_at)
     42    VALUES ('d3','me','',NULL,NULL,'https://r.test/u/g','@g@r.test','<p>help</p>','direct','["https://r.test/u/g"]',1,CURRENT_TIMESTAMP)`).run();
     43  const row = db.prepare('SELECT * FROM ap_outbox WHERE id = ?').get('d3');
     44  const note = AP.buildReplyNote('https://test.example', site, row);
     45  assert.equal(note['shaer:helpRequest'], true);
     46  assert.deepEqual(note.cc, []);   // still strictly direct
     47  // and the namespace is declared, so the term is valid JSON-LD
     48  const ctx = AP.AP_CONTEXT.find((p) => p && typeof p === 'object');
     49  assert.equal(ctx.shaer, 'https://ns.klonkt.com/shaer#');
     50  // a plain direct note (no flag) does NOT carry the term
     51  const plainRow = db.prepare('SELECT * FROM ap_outbox WHERE id = ?').get('d1');
     52  assert.equal(AP.buildReplyNote('https://test.example', site, plainRow)['shaer:helpRequest'], undefined);
     53});
     54
    4055test('direct without any real recipient is refused (400 no_recipients)', async () => {
    4156  const r = await AP.ingestOutboxActivity(site, user, {
Note: See TracChangeset for help on using the changeset viewer.