feat: chat — search, notifications room, settings

- Migration 071: nullable sender_id, is_system flag, notifications room type
- Backend: notifications room auto-created per hotel, search messages endpoint,
  notify endpoint (manager/admin posts system messages), read-only enforcement
- API: ChatSearchResult type, chat.search(), chat.notify(), updated ChatMessage type
- Frontend ChatWidget: search view (people + messages tabs), settings panel
  (notifications visibility toggle, sound toggle), notifications room (bell icon,
  read-only banner, amber styling for system messages), new-chat button

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 11:25:40 +03:00
parent 291d45622b
commit 3c4c40da44
4 changed files with 594 additions and 88 deletions

View File

@@ -0,0 +1,15 @@
-- Make sender_id nullable to support system messages
ALTER TABLE chat_messages ALTER COLUMN sender_id DROP NOT NULL;
-- Add system message fields
ALTER TABLE chat_messages ADD COLUMN IF NOT EXISTS is_system BOOLEAN NOT NULL DEFAULT false;
ALTER TABLE chat_messages ADD COLUMN IF NOT EXISTS system_name TEXT;
-- Expand room type to include notifications
ALTER TABLE chat_rooms DROP CONSTRAINT IF EXISTS chat_rooms_type_check;
ALTER TABLE chat_rooms ADD CONSTRAINT chat_rooms_type_check
CHECK (type IN ('general', 'direct', 'notifications'));
-- One notifications room per hotel
CREATE UNIQUE INDEX IF NOT EXISTS uniq_chat_rooms_notifications_hotel
ON chat_rooms(hotel_id) WHERE type = 'notifications';