From ddbee35bc15e858e5b22e622f86ea6b9ea639213 Mon Sep 17 00:00:00 2001 From: Yee Jia Rong <28086837+fourjr@users.noreply.github.com> Date: Sat, 7 Aug 2021 21:23:24 +0800 Subject: [PATCH] Persistent notes are now properly deleted,resolve #3013 --- CHANGELOG.md | 2 ++ core/thread.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6952839164..e7dc84c3d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ v3.10 adds group conversations while resolving othre bugs and QOL changes. It is - Invalid arguments are now properly catched and a proper error message is sent. - Update database after resetting/purging all plugins. ([GH #3011](https://github.com/kyb3r/modmail/pull/3011)) - `thread_auto_close` timer now only resets on non-note and replies from mods. ([GH #3030](https://github.com/kyb3r/modmail/issues/3030)) +- Deleted messages are now deleted on both ends. ([GH #3041](https://github.com/kyb3r/modmail/issues/3041), [@JerrieAries](https://github.com/kyb3r/modmail/commit/20b31f8e8b5497943513997fef788d72ae668438)) +- Persistent notes are now properly deleted from the database. ([GH #3013](https://github.com/kyb3r/modmail/issues/3013)) ## Internal diff --git a/core/thread.py b/core/thread.py index 89cdceb903..b34e14ed01 100644 --- a/core/thread.py +++ b/core/thread.py @@ -679,13 +679,17 @@ async def delete_message( else: message1, *message2 = await self.find_linked_messages(message, note=note) tasks = [] + if not isinstance(message, discord.Message): tasks += [message1.delete()] - elif message2 is not [None]: - for m2 in message2: + + for m2 in message2: + if m2 is not None: tasks += [m2.delete()] - elif message1.embeds[0].author.name.startswith("Persistent Note"): + + if message1.embeds[0].author.name.startswith("Persistent Note"): tasks += [self.bot.api.delete_note(message1.id)] + if tasks: await asyncio.gather(*tasks)