mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-06 06:41:56 +00:00
feat(hub,web): support scheduling messages for future delivery (#590)
This commit is contained in:
@@ -187,8 +187,8 @@ export class SyncEngine {
|
||||
return this.messageService.getMessagesPageByPosition(sessionId, options)
|
||||
}
|
||||
|
||||
getMessagesAfter(sessionId: string, options: { afterSeq: number; limit: number }): DecryptedMessage[] {
|
||||
return this.messageService.getMessagesAfter(sessionId, options)
|
||||
getDeliverableMessagesAfter(sessionId: string, options: { afterSeq: number; limit: number; now: number }): DecryptedMessage[] {
|
||||
return this.messageService.getDeliverableMessagesAfter(sessionId, options)
|
||||
}
|
||||
|
||||
handleRealtimeEvent(event: SyncEvent): void {
|
||||
@@ -271,6 +271,9 @@ export class SyncEngine {
|
||||
this.triggerDedupIfNeeded(session.id)
|
||||
}
|
||||
this.machineCache.expireInactive()
|
||||
// Piggybacked on the inactivity tick; not a logical part of expireInactive
|
||||
// but shares its 5s cadence (avoids a second timer).
|
||||
this.messageService.releaseMatureScheduledMessages(Date.now())
|
||||
}
|
||||
|
||||
private reloadAll(): void {
|
||||
@@ -308,6 +311,7 @@ export class SyncEngine {
|
||||
previewUrl?: string
|
||||
}>
|
||||
sentFrom?: 'telegram-bot' | 'webapp'
|
||||
scheduledAt?: number | null
|
||||
}
|
||||
): Promise<void> {
|
||||
await this.messageService.sendMessage(sessionId, payload)
|
||||
@@ -321,6 +325,10 @@ export class SyncEngine {
|
||||
return this.messageService.cancelQueuedMessage(sessionId, messageId)
|
||||
}
|
||||
|
||||
sweepImmediateQueuedOnSessionEnd(sessionId: string, invokedAt: number): void {
|
||||
this.messageService.sweepImmediateQueuedOnSessionEnd(sessionId, invokedAt)
|
||||
}
|
||||
|
||||
async approvePermission(
|
||||
sessionId: string,
|
||||
requestId: string,
|
||||
|
||||
Reference in New Issue
Block a user