Skip to content

Commit 97d0e8d

Browse files
authored
Update thread.py
Signed-off-by: lorenzo132 <[email protected]>
1 parent bd7c4c2 commit 97d0e8d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

core/thread.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,22 @@ async def restore_from_snooze(self):
270270
# Store snooze_data for notification before clearing
271271
snooze_data_for_notify = self.snooze_data
272272
self.snooze_data = None
273-
# Update channel_id in DB and clear snooze_data (robust: try recipient.id, then channel_id)
274-
result = await self.bot.api.logs.update_one(
275-
{"recipient.id": str(self.id)},
276-
{"$set": {"snoozed": False, "channel_id": str(channel.id)}, "$unset": {"snooze_data": ""}},
277-
)
278-
if result.modified_count == 0:
273+
# Update channel_id in DB and clear snooze_data (robust: try log_key first)
274+
if self.log_key:
275+
result = await self.bot.api.logs.update_one(
276+
{"key": self.log_key},
277+
{"$set": {"snoozed": False, "channel_id": str(channel.id)}, "$unset": {"snooze_data": ""}},
278+
)
279+
else:
279280
result = await self.bot.api.logs.update_one(
280-
{"channel_id": str(channel.id)},
281+
{"recipient.id": str(self.id)},
281282
{"$set": {"snoozed": False, "channel_id": str(channel.id)}, "$unset": {"snooze_data": ""}},
282283
)
284+
if result.modified_count == 0:
285+
result = await self.bot.api.logs.update_one(
286+
{"channel_id": str(channel.id)},
287+
{"$set": {"snoozed": False, "channel_id": str(channel.id)}, "$unset": {"snooze_data": ""}},
288+
)
283289
import logging
284290

285291
logging.info(f"[UNSNOOZE] DB update result: {result.modified_count}")

0 commit comments

Comments
 (0)