source: Klonkt/src/services/guardianship/notes.js@ c628dcd4

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

FEP-633c §2.2: shaer:hasGuardians (outbound stempelen, inbound registreren)

Objecten van een ward krijgen nu de advies-hint shaer:hasGuardians, zodat een
remote server interacties met de post naar de guardians kan routen zonder eerst
de actor op te halen. Veilig te negeren door wie geen shaer spreekt.

Outbound: elke Note die een ward publiceert wordt gestempeld (alle drie de
buildNote-paden: gewone post, paid-teaser, reply/direct), dus ook via buildCreate
in de outbox. Inbound: de hint wordt alleen GEREGISTREERD op het opgeslagen object
(ap_timeline.has_guardians / ap_mentions.has_guardians), nog geen actie. Wordt
later bekendgemaakt bij reddings-boei / escalatie-routing (Robins besluit).

Changed files:
src/services/guardianship/notes.js

  • hasGuardiansProps(slug) (stempel als de site guardians heeft) + objectHasGuardians(o)

src/services/guardianship/index.js

  • beide geexporteerd

src/services/ActivityPubService.js

  • buildNote stempelt in alle drie de return-paden; inbound zet has_guardians op timeline + mention

src/config/database.js

  • ap_timeline.has_guardians + ap_mentions.has_guardians

test/has-guardians.test.js

  • ward stempelt wel, free niet; objectHasGuardians leest de hint

remarks: npm test 170/170. Alleen ward-objecten dragen de hint; niks acteert er nog
op (register-only). Daemon heeft de constante al (dead_code); wiren kan later.

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

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * Guardianship (FEP-633c) — note properties.
3 *
4 * The shaer:helpRequest flag (spec 5.2.1): a ward's call for help, only ever
5 * on direct notes. Everyone who does not speak shaer can ignore it.
6 */
7import { listGuardians } from './relations.js';
8
9/**
10 * shaer:hasGuardians (§2.2): an advisory OBJECT hint that the author is a ward,
11 * so a remote server can route interactions to the guardians WITHOUT fetching
12 * the actor. Stamped on every object a ward publishes; MUST be safely ignorable.
13 */
14export function hasGuardiansProps(slug) {
15 try { return (slug && listGuardians(slug).length) ? { 'shaer:hasGuardians': true } : {}; }
16 catch { return {}; }
17}
18
19/** True when an incoming object carries the ward hint (§2.2). Register-only for
20 * now; acted on later at reddings-boei / escalation routing. */
21export function objectHasGuardians(o) {
22 return !!o && (o['shaer:hasGuardians'] === true || o.hasGuardians === true);
23}
24
25/** Extra JSON-LD properties for an outgoing note built from an ap_outbox row. */
26export function helpRequestProps(post) {
27 return (post && post.visibility === 'direct' && post.help_request)
28 ? { 'shaer:helpRequest': true }
29 : {};
30}
31
32/** True when an incoming (C2S or S2S) note object carries the flag. */
33export function isHelpRequest(object) {
34 return !!object && (object['shaer:helpRequest'] === true || object.helpRequest === true);
35}
36
37/** shaer:wave: a gentle "thinking of you" from a guardian to its ward. A
38 * private nudge, never a feed post; non-shaer clients see a plain DM. */
39export function waveProps(post) {
40 return (post && post.visibility === 'direct' && post.wave)
41 ? { 'shaer:wave': true }
42 : {};
43}
44
45/** True when an incoming note is a wave. */
46export function isWave(object) {
47 return !!object && (object['shaer:wave'] === true || object.wave === true);
48}
49
50export default { helpRequestProps, isHelpRequest, waveProps, isWave, hasGuardiansProps, objectHasGuardians };
Note: See TracBrowser for help on using the repository browser.