Mercurial Hosting > chat
diff src/lib/Chat.luan @ 57:c420f39eb474
chatuser_key
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 04 Mar 2025 07:05:12 -0700 |
parents | d21ae4920aac |
children | 7b6691bd65c3 |
line wrap: on
line diff
--- a/src/lib/Chat.luan Tue Mar 04 07:00:42 2025 -0700 +++ b/src/lib/Chat.luan Tue Mar 04 07:05:12 2025 -0700 @@ -62,22 +62,22 @@ error() end - local function get_chatuser_id(user) + local function get_chatuser_key(user) return chat.id.."~"..user.id end function chat.unread(user) - local doc = Db.get_document("chatuser_id:"..get_chatuser_id(user)) + local doc = Db.get_document("chatuser_key:"..get_chatuser_key(user)) local read_date = doc and doc.read_date or 0 return Db.count("+post_chat_id:"..chat.id.." +post_date:["..read_date.." TO *]") end function chat.read(user) run_in_transaction( function() - local chatuser_id = get_chatuser_id(user) - local doc = Db.get_document("chatuser_id:"..chatuser_id) or { + local chatuser_key = get_chatuser_key(user) + local doc = Db.get_document("chatuser_key:"..chatuser_key) or { type = "chatuser" - chatuser_id = chatuser_id + chatuser_key = chatuser_key chatuser_chat_id = chat.id or error() } doc.read_date = time_now()