Chat messages can now be rewritten by their author only, at any time, with a "(edited)" marker whose tooltip carries the full date and time down to the second. The edit is enforced by the SQL filter on user_id, so a message of someone else answers 404, exactly like a message that does not exist. Several messages can be pinned at once in the same chat room. Pinning is open to every member of the room: it is a reading convenience, not a way to take over someone else's content. A dedicated GET on /chat/pins is required because the id cursor only reports recent messages, and pinning an old one would otherwise stay invisible. The message list is synchronised with two cursors: the id one for new messages, a timestamp one for rewrites. The server computes that timestamp before running the query and returns it as-is, in the very frame used by edited_at, so the client never converts it and cannot drift by a timezone offset. Files can now be dropped on the current folder or on any sub-folder card. The drop zone only reacts to file drags, and the pointer moving from a child element to another no longer makes the overlay flicker. A deleted message leaves the pinned list, and its physical file is removed from the disk as before.
26 lines
1.3 KiB
SQL
26 lines
1.3 KiB
SQL
-- 009_chat_edits_and_pins.sql
|
|
--
|
|
-- 1. Edition des messages : `edited_at` enregistre l'instant de la derniere
|
|
-- modification. NULL signifie que le message n'a jamais ete edite, donc
|
|
-- l'interface n'affiche aucune mention. La colonne est posee par le
|
|
-- serveur, jamais par le client.
|
|
--
|
|
-- `edited_at` suit exactement la convention de `created_at` (meme horloge
|
|
-- de la base, meme cadran) : les deux colonnes doivent afficher la meme
|
|
-- heure relative l'une a l'autre, sinon la mention « (modifié) » paraitrait
|
|
-- anterieure au message qu'elle annote.
|
|
--
|
|
-- 2. Epinglage : `is_pinned` marque les messages mis de cote dans le salon.
|
|
-- Plusieurs messages peuvent etre epingles en meme temps. L'index sert a
|
|
-- retrouver les epingles d'un dossier sans parcourir tout le salon.
|
|
--
|
|
-- L'index sur `edited_at` sert au curseur `editedAfter` de la lecture
|
|
-- incrementale : il rattrape les messages reecrits dont le curseur
|
|
-- d'identifiant ne peut pas dire grand-chose.
|
|
|
|
ALTER TABLE chat_messages
|
|
ADD COLUMN edited_at DATETIME(3) NULL AFTER created_at,
|
|
ADD COLUMN is_pinned TINYINT(1) NOT NULL DEFAULT 0 AFTER edited_at,
|
|
ADD KEY idx_chat_messages_pinned (folder_id, is_pinned, id),
|
|
ADD KEY idx_chat_messages_edited (folder_id, edited_at);
|