fix: generate distinct messageId and UIDs for self-send inbox copy#269
Closed
moltboie wants to merge 1 commit intohoiekim:mainfrom
Closed
fix: generate distinct messageId and UIDs for self-send inbox copy#269moltboie wants to merge 1 commit intohoiekim:mainfrom
moltboie wants to merge 1 commit intohoiekim:mainfrom
Conversation
Contributor
Author
Self-ReviewDiscussion thread status:
Checked:
E2E Testing:
Issues found:
Confidence: High |
Contributor
Author
Self-ReviewDiscussion thread status:
Checked:
E2E Testing:
Issues found:
Confidence: Medium (pending CI) |
463e1c7 to
953285a
Compare
When sending to yourself, the inbox copy used the same messageId as the sent mail, violating the (user_id, message_id) unique constraint. Fix: generate a new randomUUID-based messageId and fetch fresh UID sequence values (domain + account) for the inbox copy so both records have unique identifiers. Closes hoiekim#147
953285a to
763944f
Compare
Owner
|
We don't save copy for sent messages anymore. Consider closing PR |
Contributor
Author
|
Closing — since sent mail copies are no longer saved, the duplicate key issue this PR fixed no longer applies. The fix is moot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the duplicate key constraint violation when sending email to yourself.
Root Cause
sendMail()saved the sent copy, then tried to save an inbox copy using the samemessageId(and same UIDs). The(user_id, message_id)unique constraint rejected the second insert:Fix
When
isToMyself()is true, generate fresh identifiers for the inbox copy:messageId—randomUUID()-based, distinct from the sent copyuid— fresh domain + account UID sequence values fetched withsent=falseTesting
Closes #147