feat(v0.8.646): Phase 671 idempotent pin gossip ingest
MESSAGE_PIN handler respects LWW pinnedAt and processes removed payloads for mesh-consistent unpin fanout. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -335,9 +335,27 @@ class PearcordGuild extends EventEmitter {
|
||||
this._ingestChannelDelete(payload).catch(() => {})
|
||||
}
|
||||
if (method === RPC.MESSAGE_PIN) {
|
||||
this.db.insert(COLLECTIONS.PINS, payload).then(() => {
|
||||
this.emit('pin', payload)
|
||||
}).catch(() => {})
|
||||
if (payload?.removed) {
|
||||
this.db
|
||||
.delete(COLLECTIONS.PINS, {
|
||||
channelId: payload.channelId,
|
||||
messageId: payload.messageId
|
||||
})
|
||||
.then(() => this.emit('pin', payload))
|
||||
.catch(() => {})
|
||||
return
|
||||
}
|
||||
this.db
|
||||
.get(COLLECTIONS.PINS, {
|
||||
channelId: payload.channelId,
|
||||
messageId: payload.messageId
|
||||
})
|
||||
.then((prev) => {
|
||||
if (prev && (prev.pinnedAt || 0) >= (payload.pinnedAt || 0)) return prev
|
||||
return this.db.insert(COLLECTIONS.PINS, payload)
|
||||
})
|
||||
.then(() => this.emit('pin', payload))
|
||||
.catch(() => {})
|
||||
}
|
||||
if (method === RPC.MEMBER_BAN) {
|
||||
this.db.insert(COLLECTIONS.BANS, payload).then(() => {
|
||||
|
||||
Reference in New Issue
Block a user