Changeset 9e4e4ff in Klonkt


Ignore:
Timestamp:
06/27/2026 08:17:34 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
cb95343
Parents:
c21197a
Message:

feat(ap): self-heal also re-syncs NSFW/sensitive + CW onto cached Cirkel posts

selfHealTimeline now refreshes ap_timeline.nsfw/cw from the re-fetched Note's
sensitive/summary (so already-cached remote posts blur retroactively). Bump
SELFHEAL_VERSION 1→2 → runs once per instance on next boot.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rc21197a r9e4e4ff  
    11741174// during a flux window, e.g. a fleet-wide update), and drops notes that are gone
    11751175// (404/410). Bump SELFHEAL_VERSION only on a release that warrants a re-sync.
    1176 const SELFHEAL_VERSION = 1;
     1176const SELFHEAL_VERSION = 2;
    11771177async function fetchNoteAP(url) {
    11781178  try {
     
    12001200    if (cur >= SELFHEAL_VERSION) return; // already healed for this version — skip on normal boots
    12011201    let rows = [];
    1202     try { rows = db.prepare('SELECT id, content, media_json FROM ap_timeline ORDER BY rowid DESC LIMIT 200').all(); } catch { /* no table */ }
     1202    try { rows = db.prepare('SELECT id, content, media_json, nsfw, cw FROM ap_timeline ORDER BY rowid DESC LIMIT 200').all(); } catch { /* no table */ }
    12031203    let healed = 0;
    12041204    for (const r of rows) {
     
    12091209        const html = HtmlSanitizerService.sanitize(note.content || '');
    12101210        const media = mediaFromNote(note);
    1211         if ((html && html !== r.content) || media !== (r.media_json || '[]')) {
    1212           db.prepare('UPDATE ap_timeline SET content = ?, media_json = ? WHERE id = ?').run(html || r.content, media, r.id);
     1211        const nsfw = note.sensitive ? 1 : 0;   // re-sync NSFW/sensitive + CW onto already-cached posts
     1212        const cw = note.summary || null;
     1213        if ((html && html !== r.content) || media !== (r.media_json || '[]') || nsfw !== (r.nsfw || 0) || (cw || '') !== (r.cw || '')) {
     1214          db.prepare('UPDATE ap_timeline SET content = ?, media_json = ?, nsfw = ?, cw = ? WHERE id = ?').run(html || r.content, media, nsfw, cw, r.id);
    12131215          healed++;
    12141216        }
Note: See TracChangeset for help on using the changeset viewer.