From c9f37ea2b6eda57000898ffb90a334eca4907f55 Mon Sep 17 00:00:00 2001 From: profitroll Date: Mon, 6 May 2024 12:47:09 +0200 Subject: [PATCH] Fixed deletion not working properly --- locale/en.json | 1 + locale/uk.json | 1 + plugins/callbacks/submission.py | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/locale/en.json b/locale/en.json index cb1c080..fd3b2af 100644 --- a/locale/en.json +++ b/locale/en.json @@ -32,6 +32,7 @@ "sub_yes_auto": "✅ Submission automatically accepted", "sub_no": "❌ Submission reviewed and declined", "sub_dup": "⚠️ Submission automatically declined because database already contains this photo", + "sub_deleted": "⚠️ Submission's database record ({0}) is not available.", "sub_blocked": "You were blocked and you can't submit media anymore.", "sub_unblocked": "You were unblocked and you can now submit media.", "sub_by": "\n\nSubmitted by:", diff --git a/locale/uk.json b/locale/uk.json index 4ea1778..d81dae0 100644 --- a/locale/uk.json +++ b/locale/uk.json @@ -31,6 +31,7 @@ "sub_yes_auto": "✅ Подання автоматично прийнято", "sub_no": "❌ Подання розглянуто та відхилено", "sub_dup": "⚠️ Подання автоматично відхилено через наявність цього фото в базі даних", + "sub_deleted": "⚠️ Запис подання у базі даних ({0}) недоступний.", "sub_blocked": "Вас заблокували, ви більше не можете надсилати медіафайли.", "sub_unblocked": "Вас розблокували, тепер ви можете надсилати медіафайли.", "sub_by": "\n\nПредставлено:", diff --git a/plugins/callbacks/submission.py b/plugins/callbacks/submission.py index 330693c..1a5183f 100644 --- a/plugins/callbacks/submission.py +++ b/plugins/callbacks/submission.py @@ -137,6 +137,15 @@ async def callback_query_no(app: PyroClient, callback: CallbackQuery): db_entry = await col_submitted.delete_one({"_id": ObjectId(fullcallback[2])}) + if db_entry.deleted_count == 0: + await callback.answer( + text=app._("sub_deleted", "callback", locale=user.locale).format( + fullcallback[2] + ), + show_alert=True, + ) + return + if ( db_entry.raw_result["temp"]["uuid"] is not None and Path(