feat(system): implement graceful shutdown and expand websocket events

Improve system reliability and real-time capabilities by implementing a robust lifecycle management system and adding new broadcast events for attachments and voice recordings.

- Implement asynchronous graceful shutdown in backend to close HTTP, WebSocket, Redis, and database connections.
- Add new WebSocket broadcast events: `attachment_created`, `voice_recording_started`, `voice_recording_stopped`, `voice_recording_uploaded`, and `analysis_queue_status`.
- Refactor media status handling to use boolean `playing` state instead of string-based status.
- Centralize `PageResult` and `VoiceRecording` types to improve consistency between frontend and backend.
- Update frontend API client to include `listRecordings` and handle new WebSocket event types.
- Fix type mismatches in voice command handling and media status reporting.
This commit is contained in:
MythEclipse
2026-06-09 16:56:44 +07:00
parent 3a7b005d95
commit 7108f6bb47
14 changed files with 161 additions and 90 deletions
@@ -1,3 +1,4 @@
import type { PageResult } from "@bete/shared";
import { createChildLogger } from "@bete/shared/logger";
import { getPool } from "../../shared/database/index.js";
import type {
@@ -8,11 +9,6 @@ import type {
const logger = createChildLogger("messages.repository");
export interface PageResult<T> {
data: T[];
nextCursor: string | null;
}
export interface AttachmentResult {
id: string;
message_id: string;