新增撤回消息推送

This commit is contained in:
xuncha
2026-04-25 00:57:24 +08:00
parent d1741c931f
commit 032aad6539
4 changed files with 778 additions and 37 deletions

View File

@@ -290,7 +290,8 @@ class HttpService {
broadcastMessagePush(payload: Record<string, unknown>): void {
if (!this.running) return
const eventId = this.nextMessagePushEventId()
const eventBody = `id: ${eventId}\nevent: message.new\ndata: ${JSON.stringify(payload)}\n\n`
const eventName = this.getMessagePushEventName(payload)
const eventBody = `id: ${eventId}\nevent: ${eventName}\ndata: ${JSON.stringify(payload)}\n\n`
this.rememberMessagePushEvent(eventId, eventBody)
if (this.messagePushClients.size === 0) return
@@ -308,6 +309,11 @@ class HttpService {
}
}
private getMessagePushEventName(payload: Record<string, unknown>): string {
const eventName = String(payload?.event || '').trim()
return /^[a-z0-9._-]+$/i.test(eventName) ? eventName : 'message.new'
}
async autoStart(): Promise<void> {
const enabled = this.configService.get('httpApiEnabled')
if (enabled) {