fix: prevent deleteUserMessages crash when hard-deleting a self-quoting message#1741
Merged
oliverlaz merged 1 commit intoMay 12, 2026
Merged
Conversation
…ng message When a hard-deleted user's cached messages include one that quotes another message from the same user, deleteUserMessages threw "Cannot read property 'cid' of undefined" mid-iteration and aborted the surrounding dispatchEvent chain. The first loop branch replaced messages[i] with the stripped hard-delete shape (no quoted_message field); the second branch then read messages[i].quoted_message (now undefined) and passed it into toDeletedMessage. Guard the second branch so it skips when the parent's quoted_message has already been stripped. Every other code path stays byte-identical. Closes #1736
Contributor
|
Size Change: +21 B (+0.01%) Total Size: 381 kB 📦 View Changed
|
MartinCupela
approved these changes
May 12, 2026
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.
Description of the changes, What, Why and How?
Closes #1736.
When the backend hard-deletes a user whose cached messages include one that quotes another message from the same user,
deleteUserMessageswas throwingCannot read property 'cid' of undefinedmid-loop, which aborted the rest of thedispatchEventchain (silently dropping downstream listeners).The loop has two branches:
message.user.id === user.id) replacesmessages[i]with the stripped hard-delete shape, which intentionally has noquoted_messagefield.message.quoted_message?.user?.id === user.id) then readsmessages[i].quoted_messageand hands it totoDeletedMessage.When both fire on the same message (i.e. a self-quote on hard-delete), B was reading an
undefinedquoted_message left behind by A. Fix is a one-line guard so B only runs when the field is still there. Soft-delete and cross-user-quote paths are unaffected, they preservemessages[i].quoted_messageand continue to work as before.