🌿 Collaborative wiki on ATProto
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update slightly noteRevision

+27 -3
+1 -1
lexicons/wiki.lichen.noteRevision.json
··· 18 18 "parentRevision": { 19 19 "type": "string", 20 20 "format": "at-uri", 21 - "description": "AT-URI of the previous revision. Null for the first revision." 21 + "description": "AT-URI of the previous revision. Omitted for the first revision of a note." 22 22 }, 23 23 "diff": { 24 24 "type": "string",
+5
src/firehose/handlers.ts
··· 340 340 case COLLECTIONS.note: 341 341 deleteNoteByAtUri(atUri); 342 342 break; 343 + case COLLECTIONS.noteRevision: 344 + // Revisions form a diff chain -- deleting one would break the chain 345 + // for all subsequent revisions. We intentionally retain the appview 346 + // copy even if the PDS record is deleted. 347 + break; 343 348 case COLLECTIONS.membership: 344 349 deleteMembershipByUri(atUri); 345 350 break;
+21 -2
src/server/db/queries/revision.ts
··· 134 134 if (exists) return; 135 135 136 136 const current = db 137 - .query("SELECT content FROM current_note WHERE note_at_uri = ?") 138 - .get(noteAtUri) as { content: string } | null; 137 + .query( 138 + "SELECT content, latest_revision_uri FROM current_note WHERE note_at_uri = ?", 139 + ) 140 + .get(noteAtUri) as { 141 + content: string; 142 + latest_revision_uri: string; 143 + } | null; 144 + 145 + // Out-of-order guard: if this revision declares a parent that doesn't match 146 + // the current head, the diff would be applied to the wrong base content. 147 + if ( 148 + parentRevisionUri && 149 + current && 150 + current.latest_revision_uri !== parentRevisionUri 151 + ) { 152 + console.warn( 153 + `[firehose] skipping out-of-order revision ${revisionAtUri}: ` + 154 + `parent ${parentRevisionUri} != head ${current.latest_revision_uri}`, 155 + ); 156 + return; 157 + } 139 158 140 159 const oldContent = current?.content ?? ""; 141 160 const newContent = applyDiff(oldContent, diff);