Audit outbound delivery and fix reviewer turn routing

This commit is contained in:
ejclaw
2026-04-10 15:22:45 +09:00
parent c67bd1c622
commit 2e62e125ae
10 changed files with 457 additions and 10 deletions

View File

@@ -601,6 +601,8 @@ export class DiscordChannel implements Channel {
attachmentCount: files.length,
messageId: sentMessageIds[0] ?? null,
messageIds: sentMessageIds,
botUserId: this.client.user?.id ?? null,
botUsername: this.client.user?.username ?? null,
},
'Discord message sent',
);
@@ -689,6 +691,18 @@ export class DiscordChannel implements Channel {
const channel = await this.client.channels.fetch(channelId);
if (!channel || !('send' in channel)) return null;
const msg = await (channel as TextChannel).send(text);
logger.info(
{
jid,
channelName: this.name,
deliveryMode: 'tracked-send',
messageId: msg.id,
botUserId: this.client.user?.id ?? null,
botUsername: this.client.user?.username ?? null,
length: text.length,
},
'Discord tracked message sent',
);
return msg.id;
} catch (err) {
logger.error({ jid, err }, 'Failed to send tracked Discord message');
@@ -696,6 +710,14 @@ export class DiscordChannel implements Channel {
}
}
getOutboundAuditMeta() {
return {
channelName: this.name,
botUserId: this.client?.user?.id ?? null,
botUsername: this.client?.user?.username ?? null,
};
}
async getChannelMeta(jids: string[]): Promise<Map<string, ChannelMeta>> {
const result = new Map<string, ChannelMeta>();
if (!this.client) return result;
@@ -813,12 +835,21 @@ export class DiscordChannel implements Channel {
deliveryMode: 'edit',
messageId,
length: text.length,
botUserId: this.client.user?.id ?? null,
botUsername: this.client.user?.username ?? null,
},
'Discord message edited',
);
} catch (err) {
logger.debug(
{ jid, channelName: this.name, messageId, err },
{
jid,
channelName: this.name,
messageId,
botUserId: this.client?.user?.id ?? null,
botUsername: this.client?.user?.username ?? null,
err,
},
'Failed to edit Discord message',
);
throw err; // Re-throw so callers (e.g. dashboard) can reset message ID