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:
Raven Scott
2026-06-02 21:09:52 -04:00
co-authored by Cursor
parent f1d0042c1b
commit ca34114421
+21 -3
View File
@@ -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(() => {