Skip to content

Commit

Permalink
Bugfix: handle contention (bluesky-social#1629)
Browse files Browse the repository at this point in the history
bugfix: handle contention
  • Loading branch information
dholms authored Sep 27, 2023
1 parent 527fc58 commit 173f3bf
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions packages/bsky/src/services/indexing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,22 @@ export class IndexingService {
const handle: string | null =
did === handleToDid ? atpData.handle.toLowerCase() : null

if (actor && actor.handle !== handle) {
const actorWithHandle =
handle !== null
? await this.db.db
.selectFrom('actor')
.where('handle', '=', handle)
.selectAll()
.executeTakeFirst()
: null
const actorWithHandle =
handle !== null
? await this.db.db
.selectFrom('actor')
.where('handle', '=', handle)
.selectAll()
.executeTakeFirst()
: null

// handle contention
if (handle && actorWithHandle && did !== actorWithHandle.did) {
await this.db.db
.updateTable('actor')
.where('actor.did', '=', actorWithHandle.did)
.set({ handle: null })
.execute()
}
// handle contention
if (handle && actorWithHandle && did !== actorWithHandle.did) {
await this.db.db
.updateTable('actor')
.where('actor.did', '=', actorWithHandle.did)
.set({ handle: null })
.execute()
}

const actorInfo = { handle, indexedAt: timestamp }
Expand Down

0 comments on commit 173f3bf

Please sign in to comment.