More features

This commit is contained in:
2026-06-10 12:43:24 -04:00
parent 02d78765bc
commit dcead245a7
12 changed files with 954 additions and 21 deletions
+28
View File
@@ -249,6 +249,34 @@ Keyword arguments: :limit N, :offset N."
(setq sql-params (nconc sql-params (list offset))))
(apply #'noise-db--query sql-str sql-params)))
(defun noise-db-mark-conversation-read (id)
"Set the unread count of conversation ID to zero."
(noise-db--exec "UPDATE conversations SET unread_count = 0 WHERE id = ?" id))
(defun noise-db-increment-unread (id)
"Increment the unread count of conversation ID by one."
(noise-db--exec
"UPDATE conversations SET unread_count = unread_count + 1 WHERE id = ?" id))
(defun noise-db-set-last-message-sender (id sender)
"Set the last-message SENDER shown in previews for conversation ID."
(noise-db--exec
"UPDATE conversations SET last_message_sender = ? WHERE id = ?" sender id))
(defun noise-db-update-receipt-state (timestamp state)
"Upgrade the receipt state of own messages with TIMESTAMP to STATE.
Only moves forward (sent < delivered < read), never downgrades."
(noise-db--exec
"UPDATE messages SET receipt_state = ?
WHERE source = 'me' AND timestamp = ?
AND (CASE receipt_state
WHEN 'read' THEN 3 WHEN 'delivered' THEN 2 WHEN 'sent' THEN 1
ELSE 0 END)
< (CASE ?
WHEN 'read' THEN 3 WHEN 'delivered' THEN 2 WHEN 'sent' THEN 1
ELSE 0 END)"
state timestamp state))
(defun noise-db-get-conversation-members (conversation-id)
"Get member contact IDs for CONVERSATION-ID."
(noise-db--query