[READ ONLY MIRROR] Spark Social AppView Server github.com/sprksocial/server
atproto deno hono lexicon
5
fork

Configure Feed

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

duplicate handling

+17 -17
-1
data-plane/indexing/plugins/block.ts
··· 26 26 indexedAt: timestamp, 27 27 }; 28 28 29 - // Use findOneAndUpdate with upsert to handle duplicates gracefully 30 29 const insertedBlock = await db.models.Block.findOneAndUpdate( 31 30 { uri: block.uri }, 32 31 { $set: block },
-1
data-plane/indexing/plugins/like.ts
··· 34 34 indexedAt: timestamp, 35 35 }; 36 36 37 - // Use findOneAndUpdate with upsert on the compound key to handle potential duplicate key errors 38 37 const insertedLike = await db.models.Like.findOneAndUpdate( 39 38 { uri: like.uri }, 40 39 { $set: like },
+17 -15
data-plane/indexing/processor.ts
··· 109 109 ? recordObj.createdAt 110 110 : timestamp; 111 111 112 + // Check for duplicates first before attempting insert 113 + const found = await this.params.findDuplicate(this.db, uri, obj); 114 + if (found && found.toString() !== uri.toString()) { 115 + // Duplicate exists with different URI, store in duplicates table with no events 116 + await this.db.models.DuplicateRecord.findOneAndUpdate( 117 + { uri: uri.toString() }, 118 + { 119 + uri: uri.toString(), 120 + cid: cid.toString(), 121 + duplicateOf: found.toString(), 122 + indexedAt: timestamp, 123 + }, 124 + { upsert: true, new: true }, 125 + ); 126 + return; 127 + } 128 + 112 129 // Insert or update record 113 130 await this.db.models.Record.findOneAndUpdate( 114 131 { uri: uri.toString() }, ··· 137 154 if (!opts?.disableNotifs) { 138 155 this.handleNotifs({ inserted }); 139 156 } 140 - return; 141 - } 142 - // if duplicate, insert into duplicates table with no events 143 - const found = await this.params.findDuplicate(this.db, uri, obj); 144 - if (found && found.toString() !== uri.toString()) { 145 - await this.db.models.DuplicateRecord.findOneAndUpdate( 146 - { uri: uri.toString() }, 147 - { 148 - uri: uri.toString(), 149 - cid: cid.toString(), 150 - duplicateOf: found.toString(), 151 - indexedAt: timestamp, 152 - }, 153 - { upsert: true, new: true }, 154 - ); 155 157 } 156 158 } 157 159