feat(review): add soft delete button to remove posts from admin channel while preserving deduplication state

This commit is contained in:
mamad
2026-08-27 22:15:43 +03:30
parent 26cd91a48f
commit e66ed361c3
4 changed files with 26 additions and 5 deletions
+18 -4
View File
@@ -93,10 +93,10 @@ class AdminBotService:
if len(row) == 2:
buttons.append(row)
row = []
if row:
buttons.append(row)
buttons.append([Button.inline("❌ رد و بایگانی پست", data=f"rej:{post.id}")])
buttons.append([
Button.inline("❌ رد و بایگانی", data=f"rej:{post.id}"),
Button.inline("🗑 حذف پیام از کانال", data=f"del_msg:{post.id}")
])
return buttons
def _format_raw_post_caption(self, post: Post) -> str:
@@ -576,6 +576,20 @@ class AdminBotService:
)
await event.answer("پست بایگانی شد.")
# 6. Soft Delete & Remove Message from Admin Channel
elif data.startswith("del_msg:"):
_, post_id_str = data.split(":")
post_id = int(post_id_str)
await self.repo.soft_delete_post(post_id)
try:
await event.delete()
except Exception as e:
logger.error(f"Could not delete message from review channel: {e}")
await event.edit("🗑 <b>این پیام حذف و بایگانی شد.</b>", parse_mode="html", buttons=None)
await event.answer("🗑 پیام از کانال ادمین حذف شد.", alert=False)
async def stop(self):
if self.client.is_connected():
await self.client.disconnect()