Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rowanseymour
Copy link
Member

@rowanseymour rowanseymour commented Oct 7, 2025

Requires changes on the RP side which currently assumes everything it reads from the history table is an event

@rowanseymour rowanseymour changed the title Add event updates to history table and save for message deletion Add event tags to history table and save for message deletion Oct 8, 2025
@rowanseymour rowanseymour marked this pull request as ready for review October 8, 2025 15:59
Copilot AI review requested due to automatic review settings October 8, 2025 15:59
Copy link

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 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.

Comment on lines +183 to +186
evtType, ok := data["type"]
if ok {
contactUUID := flows.ContactUUID(item.PK)[4:] // trim off con#
evtTypes[contactUUID] = append(evtTypes[contactUUID], evtType.(string))
Copy link

Copilot AI Oct 8, 2025

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 { ... }

Suggested change
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)

Copilot uses AI. Check for mistakes.
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')
Copy link

Copilot AI Oct 8, 2025

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.

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

codecov-commenter commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 72.72727% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.06%. Comparing base (670aa59) to head (8837793).

Files with missing lines Patch % Lines
testsuite/utils.go 0.00% 10 Missing ⚠️
core/models/msg.go 81.81% 2 Missing and 2 partials ⚠️
web/msg/delete.go 20.00% 2 Missing and 2 partials ⚠️
core/models/event.go 92.30% 1 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rowanseymour rowanseymour merged commit 330ccdb into main Oct 8, 2025
5 checks passed
@rowanseymour rowanseymour deleted the event_updates branch October 8, 2025 22:51
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants