Updated channel message.

This commit is contained in:
retoor 2025-07-18 23:20:46 +02:00
parent 04527c286f
commit f9f1179db5

View File

@ -1,6 +1,6 @@
from snek.system.service import BaseService
from snek.system.template import whitelist_attributes
import time
class ChannelMessageService(BaseService):
mapper_name = "channel_message"
@ -11,21 +11,29 @@ class ChannelMessageService(BaseService):
async def maintenance(self):
args = {}
async for message in self.find():
updated_at = message["updated_at"]
message["is_final"] = True
html = message["html"]
await self.save(message)
for message in self.mapper.db["channel_message"].find():
print(message)
try:
message = await self.get(uid=message["uid"])
updated_at = message["updated_at"]
message["is_final"] = True
html = message["html"]
await self.save(message)
self.mapper.db["channel_message"].upsert(
{
"uid": message["uid"],
"updated_at": updated_at,
},
["uid"],
)
if html != message["html"]:
print("Reredefined message", message["uid"])
except Exception as ex:
time.sleep(0.1)
print(ex, flush=True)
self.mapper.db["channel_message"].upsert(
{
"uid": message["uid"],
"updated_at": updated_at,
},
["uid"],
)
if html != message["html"]:
print("Reredefined message", message["uid"])
while True:
changed = 0
@ -91,9 +99,9 @@ class ChannelMessageService(BaseService):
if not user:
return {}
if not message["html"].startswith("<chat-message"):
message = await self.get(uid=message["uid"])
await self.save(message)
#if not message["html"].startswith("<chat-message"):
#message = await self.get(uid=message["uid"])
#await self.save(message)
return {
"uid": message["uid"],