Skip to content

Commit 8fb8274

Browse files
authored
fix: use same logkey after restoration
Signed-off-by: lorenzo132 <[email protected]>
1 parent 6164559 commit 8fb8274

File tree

2 files changed

+1695
-1723
lines changed

2 files changed

+1695
-1723
lines changed

core/clients.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ async def append_log(
648648
message: Message,
649649
*,
650650
message_id: str = "",
651-
log_key: str = None,
652651
channel_id: str = "",
653652
type_: str = "thread_message",
654653
) -> dict:
@@ -679,31 +678,14 @@ async def append_log(
679678
],
680679
}
681680

682-
# Use log_key if provided, fallback to channel_id for legacy support
683-
if log_key:
684-
return await self.logs.find_one_and_update(
685-
{"key": log_key}, {"$push": {"messages": data}}, return_document=True
686-
)
687-
else:
688-
return await self.logs.find_one_and_update(
689-
{"channel_id": channel_id}, {"$push": {"messages": data}}, return_document=True
690-
)
691-
692-
async def get_log_by_key(self, log_key: str) -> dict:
693-
return await self.logs.find_one({"key": log_key})
694-
695-
async def post_log_by_key(self, log_key: str, data: dict) -> dict:
696-
return await self.logs.find_one_and_update({"key": log_key}, {"$set": data}, return_document=True)
681+
return await self.logs.find_one_and_update(
682+
{"channel_id": channel_id}, {"$push": {"messages": data}}, return_document=True
683+
)
697684

698-
async def post_log(
699-
self, channel_id: Union[int, str] = None, data: dict = None, log_key: str = None
700-
) -> dict:
701-
if log_key:
702-
return await self.post_log_by_key(log_key, data)
703-
else:
704-
return await self.logs.find_one_and_update(
705-
{"channel_id": str(channel_id)}, {"$set": data}, return_document=True
706-
)
685+
async def post_log(self, channel_id: Union[int, str], data: dict) -> dict:
686+
return await self.logs.find_one_and_update(
687+
{"channel_id": str(channel_id)}, {"$set": data}, return_document=True
688+
)
707689

708690
async def search_closed_by(self, user_id: Union[int, str]):
709691
return await self.logs.find(

0 commit comments

Comments
 (0)