feat: add secure remote channel media

This commit is contained in:
lofyer
2026-08-09 20:33:35 +08:00
parent 6c891f3522
commit 66b098ae36
46 changed files with 4403 additions and 1594 deletions
+14
View File
@@ -1,5 +1,6 @@
import type {
ChannelInboundText,
ChannelMediaAttachment,
ChannelResultMessage
} from '../../shared/channel-contracts'
@@ -109,6 +110,7 @@ export class MemoryOutbox implements Outbox {
}
entry.state = 'delivered'
entry.attempts += 1
entry.message = this.withoutAttachments(entry.message)
}
markFailed(id: string): void {
@@ -118,6 +120,9 @@ export class MemoryOutbox implements Outbox {
}
entry.state = 'failed'
entry.attempts += 1
if (entry.attempts >= 5) {
entry.message = this.withoutAttachments(entry.message)
}
}
listUndelivered(
@@ -158,6 +163,14 @@ export class MemoryOutbox implements Outbox {
message: structuredClone(entry.message)
}
}
private withoutAttachments(
message: ChannelResultMessage
): ChannelResultMessage {
const sanitized = structuredClone(message)
delete sanitized.attachments
return sanitized
}
}
export type ChannelExecutor = (
@@ -172,4 +185,5 @@ export type ChannelExecutor = (
status: string
output?: string
error?: string
attachments?: ChannelMediaAttachment[]
}>