Changeset 4c47eff in Klonkt


Ignore:
Timestamp:
06/26/2026 12:32:50 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
bbce8da
Parents:
78b6d8a
Message:

refactor(cirkel): remove the legacy circle auto-migration (no auto-fediverse)

autoMigrateCircles auto-sent Follows on boot to re-establish legacy circle_links
as AP follows. That violates the rule 'the code never throws anything into the
fediverse automatically' — at scale it would surprise-Follow on behalf of operators
who never asked. Removed the boot call, the function, its export, and the manual
scripts/migrate-circles.mjs (bulk Follows). resolveApActor stays (used by bare-domain
follows). Dead circle_links table is left as harmless dead data; an operator restores
an old cirkel by re-following in /volgend (their own click). We can do this clean
removal now precisely because we're still small-scale.

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

Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • src/server.js

    r78b6d8a r4c47eff  
    5858import ogRoutes from './routes/og.js';
    5959import apRoutes from './routes/activitypub.js';
    60 import { apWants, startDeliveryWorker, autoMigrateCircles, selfHealTimeline } from './services/ActivityPubService.js';
     60import { apWants, startDeliveryWorker, selfHealTimeline } from './services/ActivityPubService.js';
    6161
    6262// SESSION_SECRET: use the env var if set. Otherwise auto-generate a strong one
     
    161161startScheduler(); // release planning: publish scheduled posts when publish_at is reached
    162162startDeliveryWorker(); // retry failed fediverse deliveries with backoff
    163 autoMigrateCircles(); // one-time: convert legacy circle_links -> AP auto-boost follows
    164163selfHealTimeline(); // once per SELFHEAL_VERSION bump: re-sync the fediverse cache (covers/edits) after a drastic update
    165164
  • src/services/ActivityPubService.js

    r78b6d8a r4c47eff  
    10841084}
    10851085
    1086 // One-time, best-effort migration of the old Cirkels (pull-protocol circle_links)
    1087 // into ActivityPub follows with auto-boost. Runs once per instance at boot so a
    1088 // site that updates past the old protocol keeps its cirkel without a manual step.
     1086// Resolve a Klonkt/AP actor URL from a site root: a Klonkt site's root 302s to
     1087// /ap/users/<slug> (content negotiation; Location may be relative). Used by
     1088// followActor for bare-domain follows.
     1089// NB: the old auto-migration of legacy Cirkels (circle_links -> AP follows) was
     1090// REMOVED on 2026-06-26 — it auto-sent Follows on boot, which violates "the code
     1091// never throws anything into the fediverse automatically" (would surprise-Follow
     1092// for some operators at scale). The dead circle_links table stays as harmless dead
     1093// data; an operator restores an old cirkel by re-following in /volgend (their click).
    10891094async function resolveApActor(siteUrl) {
    10901095  try {
    10911096    const r = await fetch(siteUrl, { headers: { Accept: 'application/activity+json' }, redirect: 'manual' });
    1092     // A Klonkt site's root 302s to /ap/users/<slug> (Location may be relative).
    10931097    if (r.status >= 300 && r.status < 400) { const loc = r.headers.get('location'); if (loc) return new URL(loc, siteUrl).href; }
    10941098    if (r.ok) return siteUrl;
    10951099  } catch { /* unreachable */ }
    10961100  return null;
    1097 }
    1098 let _circlesMigrating = false;
    1099 export async function autoMigrateCircles() {
    1100   if (_circlesMigrating) return; _circlesMigrating = true;
    1101   try {
    1102     let done; try { done = db.prepare('SELECT value FROM app_settings WHERE key = ?').get('circles_migrated_v2'); } catch { return; }
    1103     if (done && done.value === '1') return;
    1104     // Migrate EVERY link the user added (not only status='active'): the old
    1105     // 'error'/'outdated' statuses came from the pull-protocol's health checks
    1106     // (now irrelevant) — e.g. a peer that removed /.klonkt/* shows up as error
    1107     // but still has a working AP actor.
    1108     let links = [];
    1109     try { links = db.prepare("SELECT cl.remote_url AS url, s.id AS sid, s.slug AS slug FROM circle_links cl JOIN sites s ON s.id = cl.local_site_id WHERE cl.status != 'removed'").all(); } catch { /* no legacy table */ }
    1110     let ok = 0;
    1111     for (const l of links) {
    1112       try {
    1113         const actor = await resolveApActor(l.url);
    1114         if (actor) { const r = await followActor({ id: l.sid, slug: l.slug }, actor, true); if (!(r && r.error)) ok++; }
    1115       } catch { /* best-effort per link */ }
    1116     }
    1117     try { db.prepare('INSERT OR REPLACE INTO app_settings (key, value) VALUES (?, ?)').run('circles_migrated_v2', '1'); } catch { /* ignore */ }
    1118     if (links.length) console.log(`[AP] circle migration: ${ok}/${links.length} legacy link(s) -> auto-boost`);
    1119   } catch { /* never block boot */ } finally { _circlesMigrating = false; }
    11201101}
    11211102
     
    13711352  listOutbox, deliverOutboxDelete,
    13721353  webfingerResolve, followActor, resolveRemoteActor, unfollowActor, listFollowing, setAutoBoost, getTimeline, sendInteraction,
    1373   autoBoostCount, boostedCount, markBoosted, unmarkBoosted, getCirkelPosts, getCirkelMembers, autoMigrateCircles, selfHealTimeline, boostLatestN,
     1354  autoBoostCount, boostedCount, markBoosted, unmarkBoosted, getCirkelPosts, getCirkelMembers, selfHealTimeline, boostLatestN,
    13741355  getNotifications, listBlocks, isBlockedAny, blockTarget, unblock,
    13751356  deliverWithRetry, enqueueDelivery, processDeliveryQueue, startDeliveryWorker,
Note: See TracChangeset for help on using the changeset viewer.