fix(platform): skip duplicate announcement hub mirrors on re-gossip

Before inserting a remote hub mirror, check announcementHub.isDuplicateMirror
for the source messageId and record markMirrored after a successful insert.
Prevents duplicate 📡 mirror lines when ANNOUNCEMENT_HUB_POST is received twice.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 23:04:43 -04:00
co-authored by Cursor
parent 9adffdd408
commit c5f971a756
+22
View File
@@ -2535,6 +2535,7 @@ class PearcordPlatform extends EventEmitter {
)
const out = []
const savedGuildId = this.guild?.guild?.id
const hubMessageId = payload.messageId || null
for (const sub of subs) {
try {
const channels = await this.db.find(COLLECTIONS.CHANNELS, {
@@ -2542,6 +2543,16 @@ class PearcordPlatform extends EventEmitter {
})
const tch = channels.find((c) => c.id === sub.targetChannelId)
if (!tch || tch.type !== 'text') continue
if (hubMessageId) {
const dup = await this.announcementHub.isDuplicateMirror({
subscriberGuildId: sub.subscriberGuildId,
targetChannelId: sub.targetChannelId,
sourceGuildId: payload.sourceGuildId,
sourceChannelId: payload.sourceChannelId,
messageId: hubMessageId
})
if (dup) continue
}
if (savedGuildId !== sub.subscriberGuildId) {
await this.loadGuild(sub.subscriberGuildId)
}
@@ -2551,6 +2562,17 @@ class PearcordPlatform extends EventEmitter {
content: body,
authorId: payload.authorId || this.identity?.user?.id
})
if (hubMessageId) {
await this.announcementHub.markMirrored({
subscriberGuildId: sub.subscriberGuildId,
targetChannelId: sub.targetChannelId,
sourceGuildId: payload.sourceGuildId,
sourceChannelId: payload.sourceChannelId,
messageId: hubMessageId,
localMessageId: row.id,
postedAt: payload.postedAt
})
}
out.push(row)
} catch {
// skip invalid sub