feat(platform): GUILD_SYNC receiptRetention, hook dry-run APIs (v0.8.55)
Include receiptRetention in guild sync bundles and ingest on join. Expose dryRunAutomationHook and dryRunAllAutomationHooks for server settings preview without writing delivery receipts. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -33,7 +33,10 @@ const {
|
||||
DeliveryReceiptStore,
|
||||
AutomationHookDispatcher,
|
||||
summarizeReceipts,
|
||||
DEFAULT_MAX_AGE_MS
|
||||
DEFAULT_MAX_AGE_MS,
|
||||
buildSampleAppEvent,
|
||||
dryRunHook,
|
||||
dryRunHooks
|
||||
} = require('pearcord-delivery-receipts')
|
||||
const {
|
||||
listWorkerTemplates,
|
||||
@@ -1129,10 +1132,15 @@ class PearcordPlatform extends EventEmitter {
|
||||
permBundle = await this.channelPermissions.exportSyncBundle(guild.id)
|
||||
}
|
||||
let automationSlice = { hooks: [] }
|
||||
let receiptRetention = null
|
||||
await this._initAutomationExport(guild.id)
|
||||
if (this.automationExport) {
|
||||
automationSlice = await this.automationExport.exportSyncSlice()
|
||||
}
|
||||
await this._initDeliveryReceipts(guild.id)
|
||||
if (this.deliveryReceipts) {
|
||||
receiptRetention = await this.deliveryReceipts.exportRetentionSlice()
|
||||
}
|
||||
let automodConfig = null
|
||||
await this._ensureGuildModules()
|
||||
if (this.automod) automodConfig = await this.automod.getConfig()
|
||||
@@ -1159,6 +1167,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
channelOverwrites: permBundle.channelOverwrites,
|
||||
channelSettings,
|
||||
automationHooks: automationSlice.hooks,
|
||||
receiptRetention,
|
||||
automodConfig: automodConfig
|
||||
? {
|
||||
enabled: !!automodConfig.enabled,
|
||||
@@ -1213,6 +1222,13 @@ class PearcordPlatform extends EventEmitter {
|
||||
hooks: payload.automationHooks
|
||||
})
|
||||
}
|
||||
if (payload.receiptRetention) {
|
||||
await this._initDeliveryReceipts(payload.guildId)
|
||||
await this.deliveryReceipts.ingestRetentionSlice(
|
||||
payload.guildId,
|
||||
payload.receiptRetention
|
||||
)
|
||||
}
|
||||
if (payload.automodConfig && this.automod) {
|
||||
await this.automod.ingestGossip({
|
||||
...payload.automodConfig,
|
||||
@@ -2458,6 +2474,26 @@ class PearcordPlatform extends EventEmitter {
|
||||
return new PearcordIntegrationWorker(this, opts)
|
||||
}
|
||||
|
||||
async dryRunAutomationHook (hookId, eventType) {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
await this._initAutomationExport(this.guild.guild.id)
|
||||
const hook = await this.automationExport.getHook(hookId)
|
||||
if (!hook) throw new Error('hook not found')
|
||||
const sample = buildSampleAppEvent(this.guild.guild.id, eventType)
|
||||
return { sample, result: dryRunHook(hook, sample) }
|
||||
}
|
||||
|
||||
async dryRunAllAutomationHooks (eventType) {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
await this._initAutomationExport(this.guild.guild.id)
|
||||
const hooks = await this.automationExport.listHooks()
|
||||
const sample = buildSampleAppEvent(this.guild.guild.id, eventType)
|
||||
return {
|
||||
sample,
|
||||
results: dryRunHooks(hooks, sample)
|
||||
}
|
||||
}
|
||||
|
||||
async _initGuildVoice (guildId) {
|
||||
const user = this.identity.user
|
||||
if (!user) return
|
||||
@@ -5538,7 +5574,8 @@ class PearcordPlatform extends EventEmitter {
|
||||
const integrationWorkerTemplates = listWorkerTemplates()
|
||||
const automationHookMeta = {
|
||||
actionTypes: ACTION_TYPE_LIST,
|
||||
categoryOptions: CATEGORY_OPTIONS
|
||||
categoryOptions: CATEGORY_OPTIONS,
|
||||
dryRunEventTypes: Object.values(APP_EVENTS)
|
||||
}
|
||||
if (guild) {
|
||||
await this._initAutomationExport(guild.id)
|
||||
|
||||
Reference in New Issue
Block a user