Changeset 4c47eff in Klonkt
- Timestamp:
- 06/26/2026 12:32:50 PM (2 months ago)
- Branches:
- main
- Children:
- bbce8da
- Parents:
- 78b6d8a
- Files:
-
- 1 deleted
- 2 edited
-
scripts/migrate-circles.mjs (deleted)
-
src/server.js (modified) (2 diffs)
-
src/services/ActivityPubService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/server.js
r78b6d8a r4c47eff 58 58 import ogRoutes from './routes/og.js'; 59 59 import apRoutes from './routes/activitypub.js'; 60 import { apWants, startDeliveryWorker, autoMigrateCircles,selfHealTimeline } from './services/ActivityPubService.js';60 import { apWants, startDeliveryWorker, selfHealTimeline } from './services/ActivityPubService.js'; 61 61 62 62 // SESSION_SECRET: use the env var if set. Otherwise auto-generate a strong one … … 161 161 startScheduler(); // release planning: publish scheduled posts when publish_at is reached 162 162 startDeliveryWorker(); // retry failed fediverse deliveries with backoff 163 autoMigrateCircles(); // one-time: convert legacy circle_links -> AP auto-boost follows164 163 selfHealTimeline(); // once per SELFHEAL_VERSION bump: re-sync the fediverse cache (covers/edits) after a drastic update 165 164 -
src/services/ActivityPubService.js
r78b6d8a r4c47eff 1084 1084 } 1085 1085 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). 1089 1094 async function resolveApActor(siteUrl) { 1090 1095 try { 1091 1096 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).1093 1097 if (r.status >= 300 && r.status < 400) { const loc = r.headers.get('location'); if (loc) return new URL(loc, siteUrl).href; } 1094 1098 if (r.ok) return siteUrl; 1095 1099 } catch { /* unreachable */ } 1096 1100 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 old1105 // 'error'/'outdated' statuses came from the pull-protocol's health checks1106 // (now irrelevant) — e.g. a peer that removed /.klonkt/* shows up as error1107 // 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; }1120 1101 } 1121 1102 … … 1371 1352 listOutbox, deliverOutboxDelete, 1372 1353 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, 1374 1355 getNotifications, listBlocks, isBlockedAny, blockTarget, unblock, 1375 1356 deliverWithRetry, enqueueDelivery, processDeliveryQueue, startDeliveryWorker,
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)