Changeset 6e9bc70 in Klonkt for src/services/guardianship/delivery.js
- Timestamp:
- 10/12/2026 04:15:08 PM (2 days ago)
- Branches:
- main
- Children:
- 61d52ed
- Parents:
- 746d98a
- File:
-
- 1 edited
-
src/services/guardianship/delivery.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/guardianship/delivery.js
r746d98a r6e9bc70 14 14 import db, { NU_ISO } from '../../config/database.js'; 15 15 import { carriesGuardians } from './context.js'; 16 import * as ConversationKey from '../conversation-key.js'; 16 17 17 18 const PUBLIC = 'https://www.w3.org/ns/activitystreams#Public'; … … 33 34 if (!to.length && !cc.length) return 'public'; // no addressing at all: legacy client, keep old behavior 34 35 return 'direct'; 36 } 37 38 /** 39 * De context (FEP-7888) van het bericht waarop geantwoord wordt, als we die 40 * kennen: uit wat binnenkwam of uit wat we zelf stuurden. Een antwoord hoort in 41 * het gesprek van zijn ouder, en niet in een vers gesprek ernaast. 42 */ 43 function contextFor(slug, inReplyTo) { 44 if (!inReplyTo) return null; 45 try { 46 const binnen = db.prepare('SELECT context FROM ap_mentions WHERE slug = ? AND object_uri = ? AND context IS NOT NULL') 47 .get(slug, inReplyTo); 48 if (binnen && binnen.context) return binnen.context; 49 // Een eigen note heeft als uri .../ap/notes/<id>; de id is de outbox-sleutel. 50 const eigen = /\/ap\/notes\/([^/?#]+)$/.exec(String(inReplyTo)); 51 if (eigen) { 52 const rij = db.prepare('SELECT context FROM ap_outbox WHERE site_slug = ? AND id = ? AND context IS NOT NULL') 53 .get(slug, eigen[1]); 54 if (rij && rij.context) return rij.context; 55 } 56 } catch { /* geen context is ook een antwoord */ } 57 return null; 35 58 } 36 59 … … 144 167 .map((a) => ({ url: a.url, mediaType: String(a.mediaType), name: String(a.name || '').slice(0, 120) })); 145 168 const id = crypto.randomUUID(); 146 db.prepare(`INSERT INTO ap_outbox (id, site_slug, post_id, post_slug, in_reply_to, to_actor, to_handle, content, language, attachments, visibility, to_actors, help_request, wave, away_until, created_at) 147 VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,${NU_ISO})`) 148 .run(id, site.slug, '', null, inReplyTo || null, resolved[0].uri, resolved[0].handle, content, lang, media.length ? JSON.stringify(media) : null, 'direct', JSON.stringify(resolved.map((r) => r.uri)), helpRequest ? 1 : 0, wave ? 1 : 0, awayUntil || null); 169 // Het gesprek waar dit bij hoort (shaer-mbji): de set ontvangers. Aan Anna en 170 // Ben samen is één gesprek, en niet twee die elk de helft dragen. 171 const conv = ConversationKey.conversationKey(resolved.map((r) => r.uri)); 172 // FEP-7888: het gesprek een naam geven die andere servers ook lezen. Is dit 173 // een antwoord op iets met een context, dan hoort het in diezelfde; anders 174 // begint hier een nieuwe. 175 const context = contextFor(site.slug, inReplyTo) || `${base}/ap/contexts/${crypto.randomUUID()}`; 176 db.prepare(`INSERT INTO ap_outbox (id, site_slug, post_id, post_slug, in_reply_to, to_actor, to_handle, content, language, attachments, visibility, to_actors, help_request, wave, away_until, conv, context, created_at) 177 VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,${NU_ISO})`) 178 .run(id, site.slug, '', null, inReplyTo || null, resolved[0].uri, resolved[0].handle, content, lang, media.length ? JSON.stringify(media) : null, 'direct', JSON.stringify(resolved.map((r) => r.uri)), helpRequest ? 1 : 0, wave ? 1 : 0, awayUntil || null, conv, context); 149 179 const row = getOutboxRow(id); 150 180 const note = buildReplyNote(base, site, row);
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)