feat(platform): Phase 723 slash-registry.json and slash-invoke-audit.json mesh (v0.8.699)
Add dedicated mixins, invoke audit read/clear APIs, partition heal cursors, view meta/counts, duplicate-at export, and span renames for slash export parity. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -52,6 +52,8 @@ Application facade: one `PearcordPlatform` class that wires identity, database,
|
|||||||
|
|
||||||
**Phase 722 (v0.8.698):** Dedicated OAuth grant & install token export JSON — `oauth-grant-json-mixin.js`, `oauth-install-token-json-mixin.js`, spans `oauth-grant.json` / `oauth-install-token.json`, `getOAuthInstallTokenExportJsonExport`, `clearOAuthInstallTokenExportJsonExports`, deep links `openOAuthGrantJson` / `openOAuthInstallTokenJson`. Bundle: `npm run test:ci-phase722`.
|
**Phase 722 (v0.8.698):** Dedicated OAuth grant & install token export JSON — `oauth-grant-json-mixin.js`, `oauth-install-token-json-mixin.js`, spans `oauth-grant.json` / `oauth-install-token.json`, `getOAuthInstallTokenExportJsonExport`, `clearOAuthInstallTokenExportJsonExports`, deep links `openOAuthGrantJson` / `openOAuthInstallTokenJson`. Bundle: `npm run test:ci-phase722`.
|
||||||
|
|
||||||
|
**Phase 723 (v0.8.699):** Dedicated slash registry & invoke audit export JSON — `slash-registry-json-mixin.js`, `slash-invoke-audit-json-mixin.js`, spans `slash-registry.json` / `slash-invoke-audit.json`, `getSlashInvokeAuditExportJsonExport`, `clearSlashInvokeAuditExportJsonExports`, deep links `openSlashRegistryJson` / `openSlashInvokeAuditJson`. Bundle: `npm run test:ci-phase723`.
|
||||||
|
|
||||||
**Phase 695 (v0.8.670):** Slash registry JSON & invoke audit — `slash-json-mixin.js`, `slash.json` spans (`guildSlashRegistryCount`), `pushSlashRegistryJsonToMesh`, `pushSlashInvokeAuditExportToMesh`, deep link `openSlashJson`. Bundle: `npm run test:ci-phase695`.
|
**Phase 695 (v0.8.670):** Slash registry JSON & invoke audit — `slash-json-mixin.js`, `slash.json` spans (`guildSlashRegistryCount`), `pushSlashRegistryJsonToMesh`, `pushSlashInvokeAuditExportToMesh`, deep link `openSlashJson`. Bundle: `npm run test:ci-phase695`.
|
||||||
|
|
||||||
**Phase 692 (v0.8.667):** Digest relay handoff JSON & archive export — `relay-json-mixin.js`, `relay.json` spans, `pushDigestRelayHandoffJsonToMesh`, `pushArchivePeerExportToMesh`, deep link `openRelayJson`. Bundle: `npm run test:ci-phase692`.
|
**Phase 692 (v0.8.667):** Digest relay handoff JSON & archive export — `relay-json-mixin.js`, `relay.json` spans, `pushDigestRelayHandoffJsonToMesh`, `pushArchivePeerExportToMesh`, deep link `openRelayJson`. Bundle: `npm run test:ci-phase692`.
|
||||||
|
|||||||
@@ -1803,10 +1803,10 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const webhookExecuteJsonHeal = await this._healWebhookExecuteExportCursorOnPartition(gid).catch(() => ({
|
const webhookExecuteJsonHeal = await this._healWebhookExecuteExportCursorOnPartition(gid).catch(() => ({
|
||||||
relisted: 0
|
relisted: 0
|
||||||
}))
|
}))
|
||||||
const slashRegistryJsonHeal = await this._healSlashRegistryExportCursorOnPartition(gid).catch(() => ({
|
const slashRegistryJsonHeal = await this._healSlashRegistryJsonExportCursorOnPartition(gid).catch(() => ({
|
||||||
relisted: 0
|
relisted: 0
|
||||||
}))
|
}))
|
||||||
const slashInvokeAuditJsonHeal = await this._healSlashInvokeAuditExportCursorOnPartition(gid).catch(() => ({
|
const slashInvokeAuditJsonHeal = await this._healSlashInvokeAuditJsonExportCursorOnPartition(gid).catch(() => ({
|
||||||
relisted: 0
|
relisted: 0
|
||||||
}))
|
}))
|
||||||
const oauthGrantJsonHeal = await this._healOAuthGrantExportCursorOnPartition(gid).catch(() => ({
|
const oauthGrantJsonHeal = await this._healOAuthGrantExportCursorOnPartition(gid).catch(() => ({
|
||||||
@@ -18783,6 +18783,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
openRoleOverrideJson: !!parsed.openRoleOverrideJson,
|
openRoleOverrideJson: !!parsed.openRoleOverrideJson,
|
||||||
openOAuthGrantJson: !!parsed.openOAuthGrantJson,
|
openOAuthGrantJson: !!parsed.openOAuthGrantJson,
|
||||||
openOAuthInstallTokenJson: !!parsed.openOAuthInstallTokenJson,
|
openOAuthInstallTokenJson: !!parsed.openOAuthInstallTokenJson,
|
||||||
|
openSlashRegistryJson: !!parsed.openSlashRegistryJson,
|
||||||
|
openSlashInvokeAuditJson: !!parsed.openSlashInvokeAuditJson,
|
||||||
openChannelFollowJson: !!parsed.openChannelFollowJson,
|
openChannelFollowJson: !!parsed.openChannelFollowJson,
|
||||||
openGuildWidgetJson: !!parsed.openGuildWidgetJson
|
openGuildWidgetJson: !!parsed.openGuildWidgetJson
|
||||||
}
|
}
|
||||||
@@ -22361,8 +22363,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
|
|
||||||
async getSlashRegistryJsonExport () {
|
async getSlashRegistryJsonExport () {
|
||||||
const gid = this.guild?.guild?.id || null
|
const gid = this.guild?.guild?.id || null
|
||||||
const span = this.log.time('slash.json', {
|
const span = this.log.time('slash-registry.json', {
|
||||||
spanKind: 'slash.json',
|
spanKind: 'slash-registry.json',
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'read'
|
context: 'read'
|
||||||
})
|
})
|
||||||
@@ -22374,23 +22376,23 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
await this._initDeliveryReceipts(this.guild.guild.id)
|
await this._initDeliveryReceipts(this.guild.guild.id)
|
||||||
const row = await this.deliveryReceipts.getSlashRegistryJsonExport()
|
const row = await this.deliveryReceipts.getSlashRegistryJsonExport()
|
||||||
if (!row?.signature) {
|
if (!row?.signature) {
|
||||||
span.end({ guildSlashRegistryCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'slash.json' })
|
span.end({ guildSlashRegistryJsonCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'slash-registry.json' })
|
||||||
return row
|
return row
|
||||||
}
|
}
|
||||||
const verified = verifySlashRegistryJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, {
|
const verified = verifySlashRegistryJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, {
|
||||||
guildId: this.guild.guild.id,
|
guildId: this.guild.guild.id,
|
||||||
relaySecret: this.guild.guild.id
|
relaySecret: this.guild.guild.id
|
||||||
})
|
})
|
||||||
const out = { ...row, signatureValid: verified.ok }
|
const out = { ...row, signatureValid: verified.ok, commandCount: row.commandCount || 0 }
|
||||||
span.end({
|
span.end({
|
||||||
guildSlashRegistryCount: 1,
|
guildSlashRegistryJsonCount: 1,
|
||||||
hasSignature: true,
|
hasSignature: true,
|
||||||
signatureValid: verified.ok,
|
signatureValid: verified.ok,
|
||||||
bridgeKind: 'slash.json'
|
bridgeKind: 'slash-registry.json'
|
||||||
})
|
})
|
||||||
return out
|
return out
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('slash.json error', {
|
this.log.error('slash-registry.json error', {
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'read',
|
context: 'read',
|
||||||
error: err?.message || String(err)
|
error: err?.message || String(err)
|
||||||
@@ -22438,8 +22440,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
|
|
||||||
async pushSlashRegistryJsonToMesh () {
|
async pushSlashRegistryJsonToMesh () {
|
||||||
const gid = this.guild?.guild?.id || null
|
const gid = this.guild?.guild?.id || null
|
||||||
const span = this.log.time('slash.json', {
|
const span = this.log.time('slash-registry.json', {
|
||||||
spanKind: 'slash.json',
|
spanKind: 'slash-registry.json',
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'mesh.push'
|
context: 'mesh.push'
|
||||||
})
|
})
|
||||||
@@ -22470,13 +22472,13 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
exportedAt: exported.exportedAt
|
exportedAt: exported.exportedAt
|
||||||
})
|
})
|
||||||
span.end({
|
span.end({
|
||||||
guildSlashRegistryCount: exported.commandCount || 1,
|
guildSlashRegistryJsonCount: exported.commandCount || 1,
|
||||||
meshPushed: true,
|
meshPushed: true,
|
||||||
bridgeKind: 'slash.json'
|
bridgeKind: 'slash-registry.json'
|
||||||
})
|
})
|
||||||
return exported
|
return exported
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('slash.json error', {
|
this.log.error('slash-registry.json error', {
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'mesh.push',
|
context: 'mesh.push',
|
||||||
error: err?.message || String(err)
|
error: err?.message || String(err)
|
||||||
@@ -22563,10 +22565,68 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getSlashInvokeAuditExportJsonExport () {
|
||||||
|
const gid = this.guild?.guild?.id || null
|
||||||
|
const span = this.log.time('slash-invoke-audit.json', {
|
||||||
|
spanKind: 'slash-invoke-audit.json',
|
||||||
|
guildId: gid,
|
||||||
|
context: 'read'
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
if (!this.guild?.guild) {
|
||||||
|
span.end({ guildSlashInvokeAuditJsonCount: 0, skipped: true })
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
await this._initDeliveryReceipts(this.guild.guild.id)
|
||||||
|
const row = await this.deliveryReceipts.getSlashInvokeAuditExportJsonExport()
|
||||||
|
if (!row?.signature) {
|
||||||
|
span.end({
|
||||||
|
guildSlashInvokeAuditJsonCount: row ? 1 : 0,
|
||||||
|
hasSignature: false,
|
||||||
|
bridgeKind: 'slash-invoke-audit.json'
|
||||||
|
})
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
const verified = verifySlashInvokeAuditExportJson(
|
||||||
|
exportBodyFromSlice(row) || row.jsonBody || row.jsonBody,
|
||||||
|
row.signature,
|
||||||
|
{ guildId: this.guild.guild.id, relaySecret: this.guild.guild.id }
|
||||||
|
)
|
||||||
|
const out = { ...row, signatureValid: verified.ok, invokeCount: row.invokeCount || 0 }
|
||||||
|
span.end({
|
||||||
|
guildSlashInvokeAuditJsonCount: 1,
|
||||||
|
hasSignature: true,
|
||||||
|
signatureValid: verified.ok,
|
||||||
|
bridgeKind: 'slash-invoke-audit.json'
|
||||||
|
})
|
||||||
|
return out
|
||||||
|
} catch (err) {
|
||||||
|
this.log.error('slash-invoke-audit.json error', {
|
||||||
|
guildId: gid,
|
||||||
|
context: 'read',
|
||||||
|
error: err?.message || String(err)
|
||||||
|
})
|
||||||
|
span.fail(err)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async clearSlashInvokeAuditExportJsonExports () {
|
||||||
|
if (!this.guild?.guild) throw new Error('no guild')
|
||||||
|
const roles = await this._memberRoles()
|
||||||
|
if (!roleHasPermission(roles, PERMISSION.MANAGE_GUILD)) {
|
||||||
|
throw new Error('no permission to clear slash invoke audit JSON exports')
|
||||||
|
}
|
||||||
|
await this._initDeliveryReceipts(this.guild.guild.id)
|
||||||
|
const removed = await this.deliveryReceipts.clearSlashInvokeAuditExportJsonExports()
|
||||||
|
this.emit('slash-invoke-audit-export-json-cleared', { removed })
|
||||||
|
return { removed }
|
||||||
|
}
|
||||||
|
|
||||||
async pushSlashInvokeAuditExportToMesh () {
|
async pushSlashInvokeAuditExportToMesh () {
|
||||||
const gid = this.guild?.guild?.id || null
|
const gid = this.guild?.guild?.id || null
|
||||||
const span = this.log.time('slash.json', {
|
const span = this.log.time('slash-invoke-audit.json', {
|
||||||
spanKind: 'slash.json',
|
spanKind: 'slash-invoke-audit.json',
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'mesh.invoke'
|
context: 'mesh.invoke'
|
||||||
})
|
})
|
||||||
@@ -22598,13 +22658,13 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
meshPushed: true
|
meshPushed: true
|
||||||
}
|
}
|
||||||
span.end({
|
span.end({
|
||||||
guildSlashRegistryCount: exported.invokeCount || 0,
|
guildSlashInvokeAuditJsonCount: exported.invokeCount || 0,
|
||||||
meshPushed: true,
|
meshPushed: true,
|
||||||
bridgeKind: 'slash.json'
|
bridgeKind: 'slash-invoke-audit.json'
|
||||||
})
|
})
|
||||||
return exported
|
return exported
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('slash.json error', {
|
this.log.error('slash-invoke-audit.json error', {
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'mesh.invoke',
|
context: 'mesh.invoke',
|
||||||
error: err?.message || String(err)
|
error: err?.message || String(err)
|
||||||
@@ -32749,6 +32809,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
let lastWebhookExecuteExport = null
|
let lastWebhookExecuteExport = null
|
||||||
let slashRegistryJsonMeta = null
|
let slashRegistryJsonMeta = null
|
||||||
let slashRegistryJsonRows = []
|
let slashRegistryJsonRows = []
|
||||||
|
let slashInvokeAuditExportJsonMeta = null
|
||||||
let slashInvokeAuditExportJsonRows = []
|
let slashInvokeAuditExportJsonRows = []
|
||||||
let lastSlashInvokeAuditExport = null
|
let lastSlashInvokeAuditExport = null
|
||||||
let oauthGrantJsonMeta = null
|
let oauthGrantJsonMeta = null
|
||||||
@@ -32992,6 +33053,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
return { ...row, signatureValid: verified.ok }
|
return { ...row, signatureValid: verified.ok }
|
||||||
})
|
})
|
||||||
lastSlashInvokeAuditExport = await this.getLastSlashInvokeAuditExport()
|
lastSlashInvokeAuditExport = await this.getLastSlashInvokeAuditExport()
|
||||||
|
slashInvokeAuditExportJsonMeta =
|
||||||
|
await this.getSlashInvokeAuditExportJsonExport().catch(() => null)
|
||||||
oauthGrantJsonMeta = await this.getOAuthGrantJsonExport().catch(() => null)
|
oauthGrantJsonMeta = await this.getOAuthGrantJsonExport().catch(() => null)
|
||||||
const oauthJsonHistory = await this.deliveryReceipts.listOAuthGrantJsonExports(32)
|
const oauthJsonHistory = await this.deliveryReceipts.listOAuthGrantJsonExports(32)
|
||||||
oauthGrantJsonRows = oauthJsonHistory.map((row) => {
|
oauthGrantJsonRows = oauthJsonHistory.map((row) => {
|
||||||
@@ -33573,6 +33636,11 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
this._botRegistryJsonDuplicateAt = null
|
this._botRegistryJsonDuplicateAt = null
|
||||||
const webhookExecuteExportJsonDuplicateAt = this._webhookExecuteExportJsonDuplicateAt || null
|
const webhookExecuteExportJsonDuplicateAt = this._webhookExecuteExportJsonDuplicateAt || null
|
||||||
this._webhookExecuteExportJsonDuplicateAt = null
|
this._webhookExecuteExportJsonDuplicateAt = null
|
||||||
|
const slashRegistryJsonDuplicateAt = this._slashRegistryJsonDuplicateAt || null
|
||||||
|
this._slashRegistryJsonDuplicateAt = null
|
||||||
|
const slashInvokeAuditExportJsonDuplicateAt =
|
||||||
|
this._slashInvokeAuditExportJsonDuplicateAt || null
|
||||||
|
this._slashInvokeAuditExportJsonDuplicateAt = null
|
||||||
const oauthGrantJsonDuplicateAt = this._oauthGrantJsonDuplicateAt || null
|
const oauthGrantJsonDuplicateAt = this._oauthGrantJsonDuplicateAt || null
|
||||||
this._oauthGrantJsonDuplicateAt = null
|
this._oauthGrantJsonDuplicateAt = null
|
||||||
const oauthInstallTokenExportJsonDuplicateAt =
|
const oauthInstallTokenExportJsonDuplicateAt =
|
||||||
@@ -33783,6 +33851,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
integrationManifestExportJsonDuplicateAt,
|
integrationManifestExportJsonDuplicateAt,
|
||||||
botRegistryJsonDuplicateAt,
|
botRegistryJsonDuplicateAt,
|
||||||
webhookExecuteExportJsonDuplicateAt,
|
webhookExecuteExportJsonDuplicateAt,
|
||||||
|
slashRegistryJsonDuplicateAt,
|
||||||
|
slashInvokeAuditExportJsonDuplicateAt,
|
||||||
oauthGrantJsonDuplicateAt,
|
oauthGrantJsonDuplicateAt,
|
||||||
oauthInstallTokenExportJsonDuplicateAt,
|
oauthInstallTokenExportJsonDuplicateAt,
|
||||||
inviteLinkJsonDuplicateAt,
|
inviteLinkJsonDuplicateAt,
|
||||||
@@ -33831,8 +33901,11 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
lastWebhookExecuteExport,
|
lastWebhookExecuteExport,
|
||||||
slashRegistryJsonMeta,
|
slashRegistryJsonMeta,
|
||||||
slashRegistryJsonRows,
|
slashRegistryJsonRows,
|
||||||
|
slashInvokeAuditExportJsonMeta,
|
||||||
slashInvokeAuditExportJsonRows,
|
slashInvokeAuditExportJsonRows,
|
||||||
lastSlashInvokeAuditExport,
|
lastSlashInvokeAuditExport,
|
||||||
|
guildSlashRegistryJsonCount: (slashRegistryJsonRows || []).length,
|
||||||
|
guildSlashInvokeAuditJsonCount: (slashInvokeAuditExportJsonRows || []).length,
|
||||||
oauthGrantJsonMeta,
|
oauthGrantJsonMeta,
|
||||||
oauthGrantJsonRows,
|
oauthGrantJsonRows,
|
||||||
oauthInstallTokenExportJsonMeta,
|
oauthInstallTokenExportJsonMeta,
|
||||||
@@ -34643,6 +34716,8 @@ const { inviteLinkJsonMixin } = require('./invite-link-json-mixin')
|
|||||||
const { roleOverrideJsonMixin } = require('./role-override-json-mixin')
|
const { roleOverrideJsonMixin } = require('./role-override-json-mixin')
|
||||||
const { oauthGrantJsonMixin } = require('./oauth-grant-json-mixin')
|
const { oauthGrantJsonMixin } = require('./oauth-grant-json-mixin')
|
||||||
const { oauthInstallTokenJsonMixin } = require('./oauth-install-token-json-mixin')
|
const { oauthInstallTokenJsonMixin } = require('./oauth-install-token-json-mixin')
|
||||||
|
const { slashRegistryJsonMixin } = require('./slash-registry-json-mixin')
|
||||||
|
const { slashInvokeAuditJsonMixin } = require('./slash-invoke-audit-json-mixin')
|
||||||
Object.assign(PearcordPlatform.prototype, pollSchedulingMixin)
|
Object.assign(PearcordPlatform.prototype, pollSchedulingMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, notificationsActivityMixin)
|
Object.assign(PearcordPlatform.prototype, notificationsActivityMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, userSettingsMixin)
|
Object.assign(PearcordPlatform.prototype, userSettingsMixin)
|
||||||
@@ -34698,3 +34773,5 @@ Object.assign(PearcordPlatform.prototype, inviteLinkJsonMixin)
|
|||||||
Object.assign(PearcordPlatform.prototype, roleOverrideJsonMixin)
|
Object.assign(PearcordPlatform.prototype, roleOverrideJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, oauthGrantJsonMixin)
|
Object.assign(PearcordPlatform.prototype, oauthGrantJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, oauthInstallTokenJsonMixin)
|
Object.assign(PearcordPlatform.prototype, oauthInstallTokenJsonMixin)
|
||||||
|
Object.assign(PearcordPlatform.prototype, slashRegistryJsonMixin)
|
||||||
|
Object.assign(PearcordPlatform.prototype, slashInvokeAuditJsonMixin)
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const slashInvokeAuditJsonMixin = {
|
||||||
|
_slashInvokeAuditRegistryJsonGossipKeys: null,
|
||||||
|
_slashInvokeAuditJsonHealWatermark: null,
|
||||||
|
|
||||||
|
_initSlashInvokeAuditJsonMixinState () {
|
||||||
|
if (!this._slashInvokeAuditRegistryJsonGossipKeys) {
|
||||||
|
this._slashInvokeAuditRegistryJsonGossipKeys = new Set()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_shouldGossipSlashInvokeAuditRegistryJson (slice) {
|
||||||
|
this._initSlashInvokeAuditJsonMixinState()
|
||||||
|
if (!slice?.guildId || !slice?.signature) return true
|
||||||
|
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
|
||||||
|
if (this._slashInvokeAuditRegistryJsonGossipKeys.has(hash)) return false
|
||||||
|
this._slashInvokeAuditRegistryJsonGossipKeys.add(hash)
|
||||||
|
if (this._slashInvokeAuditRegistryJsonGossipKeys.size > 8192) {
|
||||||
|
const first = this._slashInvokeAuditRegistryJsonGossipKeys.values().next().value
|
||||||
|
if (first) this._slashInvokeAuditRegistryJsonGossipKeys.delete(first)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
|
||||||
|
async _healSlashInvokeAuditJsonExportCursorOnPartition (guildId) {
|
||||||
|
const gid = guildId || this.guild?.guild?.id || null
|
||||||
|
const span = this.log.time('slash-invoke-audit.json', {
|
||||||
|
spanKind: 'slash-invoke-audit.json',
|
||||||
|
guildId: gid,
|
||||||
|
context: 'heal.slash-invoke-audit'
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
if (!gid || !this.deliveryReceipts) {
|
||||||
|
span.end({ relisted: 0, skipped: true, guildSlashInvokeAuditJsonCount: 0 })
|
||||||
|
return { relisted: 0, skipped: true }
|
||||||
|
}
|
||||||
|
await this._initDeliveryReceipts(gid)
|
||||||
|
const rows = await this.deliveryReceipts.listSlashInvokeAuditExportJsonExports(64)
|
||||||
|
let relisted = 0
|
||||||
|
for (const row of rows) {
|
||||||
|
if (this._shouldGossipSlashInvokeAuditRegistryJson(row)) relisted++
|
||||||
|
}
|
||||||
|
const watermark = Date.now()
|
||||||
|
this._slashInvokeAuditJsonHealWatermark = watermark
|
||||||
|
span.end({
|
||||||
|
relisted,
|
||||||
|
watermark,
|
||||||
|
guildSlashInvokeAuditJsonCount: rows.length,
|
||||||
|
invokeCount: rows[0]?.invokeCount || 0,
|
||||||
|
bridgeKind: 'slash-invoke-audit.json'
|
||||||
|
})
|
||||||
|
return { relisted, watermark, guildSlashInvokeAuditJsonCount: rows.length }
|
||||||
|
} catch (err) {
|
||||||
|
this.log.error('slash-invoke-audit.json error', {
|
||||||
|
guildId: gid,
|
||||||
|
context: 'heal.slash-invoke-audit',
|
||||||
|
error: err?.message || String(err)
|
||||||
|
})
|
||||||
|
span.fail(err)
|
||||||
|
return { relisted: 0, error: err?.message || String(err) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { slashInvokeAuditJsonMixin }
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const slashRegistryJsonMixin = {
|
||||||
|
_slashRegistryExportJsonGossipKeys: null,
|
||||||
|
_slashRegistryJsonHealWatermark: null,
|
||||||
|
|
||||||
|
_initSlashRegistryJsonMixinState () {
|
||||||
|
if (!this._slashRegistryExportJsonGossipKeys) {
|
||||||
|
this._slashRegistryExportJsonGossipKeys = new Set()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_shouldGossipSlashRegistryExportJson (slice) {
|
||||||
|
this._initSlashRegistryJsonMixinState()
|
||||||
|
if (!slice?.guildId || !slice?.signature) return true
|
||||||
|
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
|
||||||
|
if (this._slashRegistryExportJsonGossipKeys.has(hash)) return false
|
||||||
|
this._slashRegistryExportJsonGossipKeys.add(hash)
|
||||||
|
if (this._slashRegistryExportJsonGossipKeys.size > 8192) {
|
||||||
|
const first = this._slashRegistryExportJsonGossipKeys.values().next().value
|
||||||
|
if (first) this._slashRegistryExportJsonGossipKeys.delete(first)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
|
||||||
|
async _healSlashRegistryJsonExportCursorOnPartition (guildId) {
|
||||||
|
const gid = guildId || this.guild?.guild?.id || null
|
||||||
|
const span = this.log.time('slash-registry.json', {
|
||||||
|
spanKind: 'slash-registry.json',
|
||||||
|
guildId: gid,
|
||||||
|
context: 'heal.slash-registry'
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
if (!gid || !this.deliveryReceipts) {
|
||||||
|
span.end({ relisted: 0, skipped: true, guildSlashRegistryJsonCount: 0 })
|
||||||
|
return { relisted: 0, skipped: true }
|
||||||
|
}
|
||||||
|
await this._initDeliveryReceipts(gid)
|
||||||
|
const rows = await this.deliveryReceipts.listSlashRegistryJsonExports(64)
|
||||||
|
let relisted = 0
|
||||||
|
for (const row of rows) {
|
||||||
|
if (this._shouldGossipSlashRegistryExportJson(row)) relisted++
|
||||||
|
}
|
||||||
|
const watermark = Date.now()
|
||||||
|
this._slashRegistryJsonHealWatermark = watermark
|
||||||
|
span.end({
|
||||||
|
relisted,
|
||||||
|
watermark,
|
||||||
|
guildSlashRegistryJsonCount: rows.length,
|
||||||
|
bridgeKind: 'slash-registry.json'
|
||||||
|
})
|
||||||
|
return { relisted, watermark, guildSlashRegistryJsonCount: rows.length }
|
||||||
|
} catch (err) {
|
||||||
|
this.log.error('slash-registry.json error', {
|
||||||
|
guildId: gid,
|
||||||
|
context: 'heal.slash-registry',
|
||||||
|
error: err?.message || String(err)
|
||||||
|
})
|
||||||
|
span.fail(err)
|
||||||
|
return { relisted: 0, error: err?.message || String(err) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { slashRegistryJsonMixin }
|
||||||
Reference in New Issue
Block a user