Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/guardianship/delivery.js

    r3d882bd ra29c8c8  
    4141// guardian on any instance receives it as a private mention (the ward
    4242// call-for-help path).
    43 export async function deliverDirectNote(site, { recipients, text, language, inReplyTo, attachments, helpRequest, wave, awayUntil }) {
     43export async function deliverDirectNote(site, { recipients, text, html, language, inReplyTo, attachments, helpRequest, wave, awayUntil, helpMark }) {
    4444  const { actorId, fetchActor, localActor, deliverTo, deriveHandle, escHtml, linkUrls, linkHashtags,
    4545          getOutboxRow, buildReplyNote, AP_CONTEXT, getOrCreateKeys, deliver, enqueueDelivery } = deps;
     
    8383    return `<a href="${escHtml(r.url)}" class="u-url mention" data-actor="${escHtml(r.uri)}">${escHtml(disp)}</a> `;
    8484  }).join('');
     85  // Rijk antwoord: `html` is de HTML uit de reply-editor, hier gesaneerd; `text`
     86  // blijft de platte versie (het `source`-veld en de no-JS-fallback). Levert de
     87  // sanitizer niets bruikbaars op, dan valt hij terug op de escaped tekst --
     88  // een leeggepoetste editor mag geen leeg bericht versturen.
     89  const richClean = html ? deps.sanitizeHtml(String(html)) : '';
     90  const rich = richClean && deps.htmlToPlainText(richClean).trim() ? richClean : '';
    8591  const body = escHtml(String(text).trim()).replace(/\r?\n/g, '<br>');
    86   const content = `<p>${mention}${linkUrls(linkHashtags(base, body))}</p>`;
     92  // De mention-anker blijft een eigen alinea vooraan: de ontvanger moet in het
     93  // bericht genoemd staan, ook als de rijke inhoud met een kop of lijst begint.
     94  const content = rich
     95    ? `<p>${mention}</p>${linkUrls(linkHashtags(base, rich))}`
     96    : `<p>${mention}${linkUrls(linkHashtags(base, body))}</p>`;
    8797  const lang = /^[a-z]{2,3}(-[A-Za-z0-9-]+)?$/.test(String(language || '')) ? language : null;
    8898  // Attachments: same rules as deliverReply (own /media/ uploads only,
     
    99109  const row = getOutboxRow(id);
    100110  const note = buildReplyNote(base, site, row);
     111  // Markering op een hulpvraag (shaer-lgo): een gewone directe note die er een
     112  // shaer:-eigenschap bij draagt, net als de zwaai. Zo reist het over dezelfde
     113  // bezorging, ziet de ward het als bericht ("er komt iemand"), en houden de
     114  // mede-guardians er staat aan over.
     115  if (helpMark && helpMark.noteUri) {
     116    note[helpMark.kind === 'handled' ? 'shaer:helpHandled' : 'shaer:helpPickup'] = helpMark.noteUri;
     117  }
    101118  const create = {
    102119    '@context': AP_CONTEXT,
Note: See TracChangeset for help on using the changeset viewer.