-
Couldn't load subscription status.
- Fork 7
Overhaul deleted message handling #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul deleted message handling #73
Conversation
This is a quick and dirty way to handle the bug, but it works. I also realised that handle_question_deletion() doesn't delete it in #tickets
TODO I''ll need to make a function that all the macros can use to send a user-facing message
while replying to a ticket
This is because the delete queue requires an admin token, ew
This is so that if someone runs ?faq, the ticket still counts as being resolved in the DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR overhauls deleted message handling by implementing a database-backed tracking system for bot messages and introducing centralized utility functions for ticket management. The changes prevent accidental deletion of tickets with meaningful bot responses and enable proper cleanup of all bot messages associated with a ticket.
Key Changes:
- Introduced
BotMessagemodel to track all bot replies in the database - Added
utils/ticket_methods.pywith centralized functions for replying to tickets, deleting bot messages, and cleaning up tickets - Updated message deletion logic to preserve threads with multiple bot messages or human replies
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| prisma/schema.prisma | Added BotMessage model with cascade deletion and unique constraints on timestamp/channel |
| nephthys/utils/ticket_methods.py | New utility module providing reply_to_ticket(), delete_bot_replies(), and delete_and_clean_up_ticket() |
| nephthys/utils/slack.py | Enhanced message deletion detection with safer property access |
| nephthys/utils/delete_thread.py | Added success logging via heartbeat messages |
| nephthys/macros/*.py | Migrated from direct chat_postMessage to reply_to_ticket() across all macro files |
| nephthys/events/message_deletion.py | Restructured deletion logic to check thread content before cleanup and use new utility functions |
| nephthys/events/message.py | Updated ticket creation to record user-facing messages and handle race conditions during processing |
| nephthys/actions/resolve.py | Migrated resolve message to use reply_to_ticket() |
| Dockerfile | Added libatomic1 dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Main technical changes:
utils/ticket_methods.pyhas been added with some utility functions for acting on ticketsreply_to_ticket()sends a reply in a ticket thread and records it in the DB. This should now be used whenever replying to a ticketdelete_bot_replies()Deletes all bot replies sent in a ticket threaddelete_and_clean_up_ticket()Removes a ticket from the DB and deletes all Slack messages associated with itBehavior changes:
?faq