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,
|
DeliveryReceiptStore,
|
||||||
AutomationHookDispatcher,
|
AutomationHookDispatcher,
|
||||||
summarizeReceipts,
|
summarizeReceipts,
|
||||||
DEFAULT_MAX_AGE_MS
|
DEFAULT_MAX_AGE_MS,
|
||||||
|
buildSampleAppEvent,
|
||||||
|
dryRunHook,
|
||||||
|
dryRunHooks
|
||||||
} = require('pearcord-delivery-receipts')
|
} = require('pearcord-delivery-receipts')
|
||||||
const {
|
const {
|
||||||
listWorkerTemplates,
|
listWorkerTemplates,
|
||||||
@@ -1129,10 +1132,15 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
permBundle = await this.channelPermissions.exportSyncBundle(guild.id)
|
permBundle = await this.channelPermissions.exportSyncBundle(guild.id)
|
||||||
}
|
}
|
||||||
let automationSlice = { hooks: [] }
|
let automationSlice = { hooks: [] }
|
||||||
|
let receiptRetention = null
|
||||||
await this._initAutomationExport(guild.id)
|
await this._initAutomationExport(guild.id)
|
||||||
if (this.automationExport) {
|
if (this.automationExport) {
|
||||||
automationSlice = await this.automationExport.exportSyncSlice()
|
automationSlice = await this.automationExport.exportSyncSlice()
|
||||||
}
|
}
|
||||||
|
await this._initDeliveryReceipts(guild.id)
|
||||||
|
if (this.deliveryReceipts) {
|
||||||
|
receiptRetention = await this.deliveryReceipts.exportRetentionSlice()
|
||||||
|
}
|
||||||
let automodConfig = null
|
let automodConfig = null
|
||||||
await this._ensureGuildModules()
|
await this._ensureGuildModules()
|
||||||
if (this.automod) automodConfig = await this.automod.getConfig()
|
if (this.automod) automodConfig = await this.automod.getConfig()
|
||||||
@@ -1159,6 +1167,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
channelOverwrites: permBundle.channelOverwrites,
|
channelOverwrites: permBundle.channelOverwrites,
|
||||||
channelSettings,
|
channelSettings,
|
||||||
automationHooks: automationSlice.hooks,
|
automationHooks: automationSlice.hooks,
|
||||||
|
receiptRetention,
|
||||||
automodConfig: automodConfig
|
automodConfig: automodConfig
|
||||||
? {
|
? {
|
||||||
enabled: !!automodConfig.enabled,
|
enabled: !!automodConfig.enabled,
|
||||||
@@ -1213,6 +1222,13 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
hooks: payload.automationHooks
|
hooks: payload.automationHooks
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (payload.receiptRetention) {
|
||||||
|
await this._initDeliveryReceipts(payload.guildId)
|
||||||
|
await this.deliveryReceipts.ingestRetentionSlice(
|
||||||
|
payload.guildId,
|
||||||
|
payload.receiptRetention
|
||||||
|
)
|
||||||
|
}
|
||||||
if (payload.automodConfig && this.automod) {
|
if (payload.automodConfig && this.automod) {
|
||||||
await this.automod.ingestGossip({
|
await this.automod.ingestGossip({
|
||||||
...payload.automodConfig,
|
...payload.automodConfig,
|
||||||
@@ -2458,6 +2474,26 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
return new PearcordIntegrationWorker(this, opts)
|
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) {
|
async _initGuildVoice (guildId) {
|
||||||
const user = this.identity.user
|
const user = this.identity.user
|
||||||
if (!user) return
|
if (!user) return
|
||||||
@@ -5538,7 +5574,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const integrationWorkerTemplates = listWorkerTemplates()
|
const integrationWorkerTemplates = listWorkerTemplates()
|
||||||
const automationHookMeta = {
|
const automationHookMeta = {
|
||||||
actionTypes: ACTION_TYPE_LIST,
|
actionTypes: ACTION_TYPE_LIST,
|
||||||
categoryOptions: CATEGORY_OPTIONS
|
categoryOptions: CATEGORY_OPTIONS,
|
||||||
|
dryRunEventTypes: Object.values(APP_EVENTS)
|
||||||
}
|
}
|
||||||
if (guild) {
|
if (guild) {
|
||||||
await this._initAutomationExport(guild.id)
|
await this._initAutomationExport(guild.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user