Changeset 5924bbf in Klonkt


Ignore:
Timestamp:
06/30/2026 01:42:44 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
2306abd
Parents:
d8e3ff7
Message:

fix(federation): self-heal also refreshes ap_timeline.url (heals dead links from a remote slug rename)

The inbound Update handler now refreshes url, but existing cached rows keep the old (dead) url
until re-fetched. selfHeal re-fetches cached notes but didn't update url either; now it does, and
SELFHEAL_VERSION 3->4 triggers a one-time re-sync at boot so already-cached renamed posts get the
correct link.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rd8e3ff7 r5924bbf  
    15001500// during a flux window, e.g. a fleet-wide update), and drops notes that are gone
    15011501// (404/410). Bump SELFHEAL_VERSION only on a release that warrants a re-sync.
    1502 const SELFHEAL_VERSION = 3;
     1502const SELFHEAL_VERSION = 4;
    15031503async function fetchNoteAP(url) {
    15041504  try {
     
    15721572    if (cur >= SELFHEAL_VERSION) return; // already healed for this version — skip on normal boots
    15731573    let rows = [];
    1574     try { rows = db.prepare('SELECT id, content, media_json, nsfw, cw FROM ap_timeline ORDER BY rowid DESC LIMIT 200').all(); } catch { /* no table */ }
     1574    try { rows = db.prepare('SELECT id, content, media_json, nsfw, cw, url FROM ap_timeline ORDER BY rowid DESC LIMIT 200').all(); } catch { /* no table */ }
    15751575    let healed = 0;
    15761576    for (const r of rows) {
     
    15831583        const nsfw = note.sensitive ? 1 : 0;   // re-sync NSFW/sensitive + CW onto already-cached posts
    15841584        const cw = note.summary || null;
    1585         if ((html && html !== r.content) || media !== (r.media_json || '[]') || nsfw !== (r.nsfw || 0) || (cw || '') !== (r.cw || '')) {
    1586           db.prepare('UPDATE ap_timeline SET content = ?, media_json = ?, nsfw = ?, cw = ? WHERE id = ?').run(html || r.content, media, nsfw, cw, r.id);
     1585        const url = note.url || null;          // re-sync the human url (catches a remote slug rename)
     1586        if ((html && html !== r.content) || media !== (r.media_json || '[]') || nsfw !== (r.nsfw || 0) || (cw || '') !== (r.cw || '') || (url && url !== r.url)) {
     1587          db.prepare('UPDATE ap_timeline SET content = ?, media_json = ?, nsfw = ?, cw = ?, url = COALESCE(?, url) WHERE id = ?').run(html || r.content, media, nsfw, cw, url, r.id);
    15871588          healed++;
    15881589        }
Note: See TracChangeset for help on using the changeset viewer.