Files
pearcord-platform/mixins/domain/threads-forum.js
T
Raven ScottandCursor a5dba86570 refactor(platform): organize mixins into category directories
Move 136 prototype mixins under mixins/domain, json-export, and
runtime/* so the package root stays navigable. Manifest assign order
is unchanged; apply-platform-mixins and runtime registry paths updated.

Co-authored-by: Cursor <[email protected]>
2026-06-03 17:42:26 -04:00

46 lines
1.5 KiB
JavaScript

'use strict'
const { COLLECTIONS, CHANNEL_TYPES } = require('pearcord-shared')
const threadsForumMixin = {
_threadHealWatermark: null,
_forumHealWatermark: null,
async _healForumTagPaletteOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('forum.heal', { spanKind: 'forum.heal', guildId: gid })
try {
if (!gid || !this.guild?.listChannels) {
span.end({ relisted: 0, skipped: true })
return { relisted: 0, skipped: true }
}
const channels = await this.guild.listChannels().catch(() => [])
let relisted = 0
for (const ch of channels) {
if (ch.type !== CHANNEL_TYPES.FORUM) continue
if (this.forum?.parsePaletteFromTopic) {
const tags = this.forum.parsePaletteFromTopic(ch.topic)
if (tags?.length) relisted += 1
}
}
const watermark = Date.now()
this._forumHealWatermark = watermark
span.end({ relisted, watermark, forumPostCount: relisted })
return { relisted, watermark }
} catch (err) {
this.log.error('forum.heal error', { guildId: gid, error: err?.message || String(err) })
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
},
listGuildThreadChannels (guildId) {
const gid = guildId || this.guild?.guild?.id || null
if (!gid) return []
const channels = this._lastViewChannelsCache || []
return channels.filter((c) => c.type === CHANNEL_TYPES.THREAD && c.guildId === gid)
}
}
module.exports = { threadsForumMixin }