-
Notifications
You must be signed in to change notification settings - Fork 3
Add event tags to history table and save for message deletion #847
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
Conversation
c0641c2 to
8db324b
Compare
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 adds event tags to the history table to track message deletion events, allowing the system to record additional information about when and how messages are deleted. The changes enable saving deletion events with user/contact information to the history table.
- Introduces EventTag model to store additional event metadata in the history table
- Updates message deletion functionality to record deletion events with user information
- Modifies test utilities to handle both events and event tags in history
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/models/event.go | Adds EventTag struct and deletion tag creation functions |
| core/models/msg.go | Updates DeleteMessages to save deletion history and require OrgAssets |
| core/models/event_test.go | Adds tests for EventTag functionality and deletion tag creation |
| core/models/msg_test.go | Updates message deletion tests to use new function signature |
| core/tasks/realtime/ctasks/msg_deleted.go | Updates to use new DeleteMessages signature with NilUserID |
| testsuite/utils.go | Modifies GetHistoryEventTypes to handle both events and event tags |
| web/msg/delete.go | Adds user_id parameter and loads org assets for deletion |
| web/msg/testdata/delete.json | Adds expected history entries for deletion events |
| core/models/testdata/eventtag_to_dynamo.json | New test data for EventTag DynamoDB serialization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| evtType, ok := data["type"] | ||
| if ok { | ||
| contactUUID := flows.ContactUUID(item.PK)[4:] // trim off con# | ||
| evtTypes[contactUUID] = append(evtTypes[contactUUID], evtType.(string)) |
Copilot
AI
Oct 8, 2025
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.
The type assertion evtType.(string) can panic if the type field is not a string. Use a safe type assertion with comma ok idiom: evtType, ok := data[\"type\"].(string); if ok { ... }
| evtType, ok := data["type"] | |
| if ok { | |
| contactUUID := flows.ContactUUID(item.PK)[4:] // trim off con# | |
| evtTypes[contactUUID] = append(evtTypes[contactUUID], evtType.(string)) | |
| if evtType, ok := data["type"].(string); ok { | |
| contactUUID := flows.ContactUUID(item.PK)[4:] // trim off con# | |
| evtTypes[contactUUID] = append(evtTypes[contactUUID], evtType) |
| WHERE org_id = $1 AND uuid = ANY($2) AND direction = 'I' | ||
| RETURNING id` | ||
| FROM contacts_contact c | ||
| WHERE c.id = msgs_msg.contact_id AND msgs_msg.org_id = $1 AND msgs_msg.uuid = ANY($2) AND msgs_msg.direction = 'I' AND msgs_msg.visibility IN ('V', 'A') |
Copilot
AI
Oct 8, 2025
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.
[nitpick] The query joins with contacts_contact to get contact UUID but this adds complexity. Consider if the contact UUID can be obtained more efficiently, or document why this join is necessary for the deletion history feature.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #847 +/- ##
==========================================
+ Coverage 49.85% 50.06% +0.21%
==========================================
Files 258 258
Lines 15151 15190 +39
==========================================
+ Hits 7553 7605 +52
+ Misses 6829 6812 -17
- Partials 769 773 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7438ecb to
8837793
Compare
Requires changes on the RP side which currently assumes everything it reads from the history table is an event