Skip to content

Conversation

@MMK21Hub
Copy link
Collaborator

Main technical changes:

  • Messages that Heidi sends in reply to tickets are now recorded in the DB.
    • Therefore we can delete them all (if required) by just looping through DB items
    • This means that messages that Heidi accidentally sends to the channel instead of a thread can be tracked and deleted
  • utils/ticket_methods.py has been added with some utility functions for acting on tickets
    • reply_to_ticket() sends a reply in a ticket thread and records it in the DB. This should now be used whenever replying to a ticket
    • delete_bot_replies() Deletes all bot replies sent in a ticket thread
    • delete_and_clean_up_ticket() Removes a ticket from the DB and deletes all Slack messages associated with it
image

Behavior changes:

  • If a thread has more than 3 messages from Heidi, it won't be nuked when the top-level message is deleted
    • This prevents tickets being lost if the only response was a ?faq

MMK21Hub and others added 27 commits October 21, 2025 23:03
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
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.
Copilot AI review requested due to automatic review settings October 24, 2025 19:11
Copy link
Contributor

Copilot AI left a 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 BotMessage model to track all bot replies in the database
  • Added utils/ticket_methods.py with 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.

@MMK21Hub MMK21Hub added this pull request to the merge queue Oct 25, 2025
Merged via the queue into hackclub:main with commit bed6f31 Oct 25, 2025
4 checks passed
@MMK21Hub MMK21Hub deleted the fix-quick-message-deletions branch October 25, 2025 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants