feat(threads): persist autoArchiveAt in thread meta rows
Store scheduled auto-archive timestamps when creating threads with autoArchiveMinutes so partition heal can archive expired threads (Phase 679). Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -141,6 +141,7 @@ class PearcordGuild extends EventEmitter {
|
||||
archived: meta.archived === true,
|
||||
createdAt: meta.createdAt || now()
|
||||
}
|
||||
if (meta.autoArchiveAt != null) row.autoArchiveAt = Number(meta.autoArchiveAt) || 0
|
||||
await this.db.insert(COLLECTIONS.THREAD_META, row)
|
||||
return row
|
||||
}
|
||||
@@ -1296,7 +1297,7 @@ class PearcordGuild extends EventEmitter {
|
||||
return merged
|
||||
}
|
||||
|
||||
async createThread ({ parentChannelId, rootMessageId, name }) {
|
||||
async createThread ({ parentChannelId, rootMessageId, name, autoArchiveMinutes = 0 }) {
|
||||
if (!this.guild) throw new Error('no active guild')
|
||||
if (!parentChannelId || !rootMessageId) {
|
||||
throw new Error('parentChannelId and rootMessageId required')
|
||||
@@ -1328,6 +1329,14 @@ class PearcordGuild extends EventEmitter {
|
||||
parentChannelId,
|
||||
{ rootMessageId, archived: false }
|
||||
)
|
||||
if (autoArchiveMinutes > 0 && channel?.id) {
|
||||
await this._upsertThreadMeta({
|
||||
guildId: this.guild.id,
|
||||
channelId: channel.id,
|
||||
rootMessageId,
|
||||
autoArchiveAt: Date.now() + autoArchiveMinutes * 60 * 1000
|
||||
}).catch(() => {})
|
||||
}
|
||||
this.emit('channel', channel)
|
||||
return channel
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user