-
Notifications
You must be signed in to change notification settings - Fork 400
feat(send_queue): send redactions via the send queue #6250
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
Open
Johennes
wants to merge
15
commits into
matrix-org:main
Choose a base branch
from
Johennes:johannes/send-queue-redactions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c288212
feat(send_queue): send redactions via the send queue
Johennes ba8f1bb
feat(timeline): handle local echoes of redactions
Johennes 9fbe8d3
fixup! feat(timeline): handle local echoes of redactions
Johennes 40f42ff
fixup! feat(timeline): handle local echoes of redactions
Johennes 08e764b
fixup! feat(timeline): handle local echoes of redactions
Johennes d34a773
fixup! feat(timeline): handle local echoes of redactions
Johennes 1d21e85
fixup! feat(send_queue): send redactions via the send queue
Johennes 9719663
fixup! feat(send_queue): send redactions via the send queue
Johennes 75896b2
Merge branch 'main' into johannes/send-queue-redactions
Johennes de1fae3
fixup! feat(send_queue): send redactions via the send queue
Johennes 5007d2f
fixup! feat(send_queue): send redactions via the send queue
Johennes 112ea05
fixup! feat(send_queue): send redactions via the send queue
Johennes 44bc666
Merge branch 'main' into johannes/send-queue-redactions
Johennes 4560ac8
fixup! feat(timeline): handle local echoes of redactions
Johennes b2007a6
Merge branch 'main' into johannes/send-queue-redactions
Johennes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,8 +215,22 @@ impl TimelineItemContent { | |
| matches!(self, Self::MsgLike(MsgLikeContent { kind: MsgLikeKind::UnableToDecrypt(_), .. })) | ||
| } | ||
|
|
||
| /// Whether the underlying event was redacted (either locally or remotely). | ||
| pub fn is_redacted(&self) -> bool { | ||
| matches!(self, Self::MsgLike(MsgLikeContent { kind: MsgLikeKind::Redacted, .. })) | ||
| matches!(self, Self::MsgLike(MsgLikeContent { kind: MsgLikeKind::Redacted { .. }, .. })) | ||
| } | ||
|
|
||
| /// Whether the underlying event was redacted locally. This means the | ||
| /// redaction was sent to the server but we're still waiting on the | ||
| /// server to acknowledge it with its remote echo. | ||
| pub fn is_redacted_locally(&self) -> bool { | ||
| matches!( | ||
| self, | ||
| Self::MsgLike(MsgLikeContent { | ||
| kind: MsgLikeKind::Redacted { unredacted_content: Some(_) }, | ||
| .. | ||
| }) | ||
| ) | ||
| } | ||
|
|
||
| // These constructors could also be `From` implementations, but that would | ||
|
|
@@ -325,10 +339,22 @@ impl TimelineItemContent { | |
| } | ||
| } | ||
|
|
||
| pub(in crate::timeline) fn redact(&self, rules: &RedactionRules) -> Self { | ||
| pub(in crate::timeline) fn redact(&self, rules: &RedactionRules, is_local: bool) -> Self { | ||
| match self { | ||
| Self::MsgLike(_) | Self::CallInvite | Self::RtcNotification => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we should handle the other |
||
| TimelineItemContent::MsgLike(MsgLikeContent::redacted()) | ||
| if is_local { | ||
| TimelineItemContent::MsgLike(MsgLikeContent { | ||
| kind: MsgLikeKind::Redacted { | ||
| unredacted_content: Some(Box::new(self.clone())), | ||
| }, | ||
| reactions: Default::default(), | ||
| thread_root: None, | ||
| in_reply_to: None, | ||
| thread_summary: None, | ||
| }) | ||
| } else { | ||
| TimelineItemContent::MsgLike(MsgLikeContent::redacted()) | ||
| } | ||
| } | ||
| Self::MembershipChange(ev) => Self::MembershipChange(ev.redact(rules)), | ||
| Self::ProfileChange(ev) => Self::ProfileChange(ev.redact()), | ||
|
|
@@ -337,6 +363,20 @@ impl TimelineItemContent { | |
| } | ||
| } | ||
|
|
||
| /// Create a clone of the current item, with content restored from the | ||
| /// item's unredacted_content (if it was previously set by a call to | ||
| /// the `redact(...)` method). | ||
| pub(in crate::timeline) fn unredact(&self) -> Self { | ||
| let Self::MsgLike(MsgLikeContent { | ||
| kind: MsgLikeKind::Redacted { unredacted_content: Some(content) }, | ||
| .. | ||
| }) = self | ||
| else { | ||
| return self.clone(); | ||
| }; | ||
| *content.clone() | ||
| } | ||
|
|
||
| /// Event ID of the thread root, if this is a message in a thread. | ||
| pub fn thread_root(&self) -> Option<OwnedEventId> { | ||
| as_variant!(self, Self::MsgLike)?.thread_root.clone() | ||
|
|
@@ -890,7 +930,7 @@ mod tests { | |
| change: Some(MembershipChange::Banned), | ||
| }); | ||
|
|
||
| let redacted = content.redact(&RedactionRules::V11); | ||
| let redacted = content.redact(&RedactionRules::V11, false); | ||
| assert_let!(TimelineItemContent::MembershipChange(inner) = redacted); | ||
| assert_eq!(inner.change, Some(MembershipChange::Banned)); | ||
| assert_let!(StateEventContentChange::Redacted(inner_content_redacted) = inner.content); | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
shouldn't this bool be based on a field of
send_errorsomehow?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.
Hm, I think not. This is actually copied from the
LocalEchoContent::Eventmatch-arm a few lines above. It seems thatsend_erroris of typeQueueWedgeErrorwhich appears to always be unrecoverable.