changeset 55:d21ae4920aac

minor fix
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 03 Mar 2025 21:42:38 -0700
parents 1d724f187cff
children 323ddacc1593
files src/lib/Chat.luan src/lib/Db.luan
diffstat 2 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/Chat.luan	Mon Mar 03 21:19:12 2025 -0700
+++ b/src/lib/Chat.luan	Mon Mar 03 21:42:38 2025 -0700
@@ -43,6 +43,7 @@
 		run_in_transaction( function()
 			local id = chat.id
 			Db.delete("post_chat_id:"..id)
+			Db.delete("chatuser_chat_id:"..id)
 			Db.delete("id:"..id)
 		end )
 	end
@@ -77,6 +78,7 @@
 			local doc = Db.get_document("chatuser_id:"..chatuser_id) or {
 				type = "chatuser"
 				chatuser_id = chatuser_id
+				chatuser_chat_id = chat.id or error()
 			}
 			doc.read_date = time_now()
 			Db.save(doc)
--- a/src/lib/Db.luan	Mon Mar 03 21:19:12 2025 -0700
+++ b/src/lib/Db.luan	Mon Mar 03 21:42:38 2025 -0700
@@ -29,6 +29,7 @@
 Db.indexed_fields.post_date = Lucene.type.long
 
 Db.indexed_fields.chatuser_id = Lucene.type.string
+Db.indexed_fields.chatuser_chat_id = Lucene.type.long
 
 function Db.not_in_transaction()
 	logger.error(new_error("not in transaction"))
@@ -42,6 +43,9 @@
 			Db.save(doc)
 		end
 	end
+	[2] = function()
+		Db.delete("type:chatuser")
+	end
 }
 
 if Http.is_serving then