Skip to content
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

chore: Update to latest Ruma version #4532

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ proptest = { version = "1.5.0", default-features = false, features = ["std"] }
rand = "0.8.5"
reqwest = { version = "0.12.4", default-features = false }
rmp-serde = "1.3.0"
ruma = { git = "https://github.com/ruma/ruma", rev = "b266343136e8470a7d040efc207e16af0c20d374", features = [
ruma = { git = "https://github.com/ruma/ruma", rev = "5c9ef9f425d8f8b330e46d215c683bf799a28d50", features = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment should be added to only update Ruma using the ruma-0.12 branch, to make sure no one tries to update using the main branch before we plan to make a breaking release?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea.

"client-api-c",
"compat-upload-signatures",
"compat-user-id",
Expand All @@ -72,7 +72,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "b266343136e8470a7d040efc20
"unstable-msc4140",
"unstable-msc4171",
] }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "b266343136e8470a7d040efc207e16af0c20d374" }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "5c9ef9f425d8f8b330e46d215c683bf799a28d50" }
serde = "1.0.151"
serde_html_form = "0.2.0"
serde_json = "1.0.91"
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-crypto/src/machine/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,8 @@ async fn test_unsigned_decryption() {

// Encrypt a second message, an edit.
let second_message_text = "This is the ~~original~~ edited message";
let second_message_content = RoomMessageEventContent::text_plain(second_message_text)
.make_replacement(first_message, None);
let second_message_content =
RoomMessageEventContent::text_plain(second_message_text).make_replacement(first_message);
let second_message_encrypted_content =
alice.encrypt_room_event(room_id, second_message_content).await.unwrap();

Expand Down
10 changes: 0 additions & 10 deletions crates/matrix-sdk-ui/src/timeline/event_item/content/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ impl Message {
self.mentions.as_ref()
}

pub(in crate::timeline) fn to_content(&self) -> RoomMessageEventContent {
// Like the `impl From<Message> for RoomMessageEventContent` below, but
// takes &self and only copies what's needed.
let relates_to = make_relates_to(
self.thread_root.clone(),
self.in_reply_to.as_ref().map(|details| details.event_id.clone()),
);
assign!(RoomMessageEventContent::new(self.msgtype.clone()), { relates_to })
}

pub(in crate::timeline) fn with_in_reply_to(&self, in_reply_to: InReplyToDetails) -> Self {
Self { in_reply_to: Some(in_reply_to), ..self.clone() }
}
Expand Down
1 change: 0 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/event_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ impl EventTimelineItem {
Ok(RepliedToInfo {
event_id: event_id.to_owned(),
sender: self.sender().to_owned(),
timestamp: self.timestamp(),
content: reply_content,
})
}
Expand Down
49 changes: 18 additions & 31 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ use ruma::{
events::{
poll::unstable_start::{NewUnstablePollStartEventContent, UnstablePollStartEventContent},
receipt::{Receipt, ReceiptThread},
relation::Thread,
room::{
message::{
AddMentions, ForwardThread, OriginalRoomMessageEvent,
RoomMessageEventContentWithoutRelation,
AddMentions, ForwardThread, ReplyMetadata, RoomMessageEventContentWithoutRelation,
},
pinned_events::RoomPinnedEventsEventContent,
},
AnyMessageLikeEventContent, AnySyncMessageLikeEvent, AnySyncTimelineEvent,
SyncMessageLikeEvent,
},
serde::Raw,
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, RoomVersionId, UserId,
EventId, OwnedEventId, OwnedUserId, RoomVersionId, UserId,
};
use thiserror::Error;
use tracing::{error, instrument, trace, warn};
Expand Down Expand Up @@ -104,8 +104,6 @@ pub struct RepliedToInfo {
event_id: OwnedEventId,
/// The sender of the event to reply to.
sender: OwnedUserId,
/// The timestamp of the event to reply to.
timestamp: MilliSecondsSinceUnixEpoch,
/// The content of the event to reply to.
content: ReplyContent,
Comment on lines 107 to 108
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the full content, I think this could store directly the thread information as an Option; then we could likely get rid of ReplyContent too, which would be nice!

}
Expand Down Expand Up @@ -343,7 +341,8 @@ impl Timeline {
replied_to_info: RepliedToInfo,
forward_thread: ForwardThread,
) -> Result<(), RoomSendQueueError> {
let event_id = replied_to_info.event_id;
let event_id = &replied_to_info.event_id;
let sender = &replied_to_info.sender;

// [The specification](https://spec.matrix.org/v1.10/client-server-api/#user-and-room-mentions) says:
//
Expand All @@ -352,32 +351,21 @@ impl Timeline {
//
// If the replied to event has been written by the current user, let's toggle to
// `AddMentions::No`.
let mention_the_sender = if self.room().own_user_id() == replied_to_info.sender {
AddMentions::No
} else {
AddMentions::Yes
let mention_the_sender =
if self.room().own_user_id() == sender { AddMentions::No } else { AddMentions::Yes };

let thread = match replied_to_info.content {
ReplyContent::Message(message) => message
.thread_root()
.map(|thread_root| Thread::plain(thread_root.clone(), event_id.clone())),
ReplyContent::Raw(_raw_event) => None,
};

let content = match replied_to_info.content {
ReplyContent::Message(msg) => {
let event = OriginalRoomMessageEvent {
event_id: event_id.to_owned(),
sender: replied_to_info.sender,
origin_server_ts: replied_to_info.timestamp,
room_id: self.room().room_id().to_owned(),
content: msg.to_content(),
unsigned: Default::default(),
};
content.make_reply_to(&event, forward_thread, mention_the_sender)
}
ReplyContent::Raw(raw_event) => content.make_reply_to_raw(
&raw_event,
event_id.to_owned(),
self.room().room_id(),
forward_thread,
mention_the_sender,
),
};
let content = content.make_reply_to(
ReplyMetadata::new(event_id, sender, thread.as_ref()),
forward_thread,
mention_the_sender,
);

self.send(content.into()).await?;

Expand Down Expand Up @@ -425,7 +413,6 @@ impl Timeline {
Ok(RepliedToInfo {
event_id: event_id.to_owned(),
sender: sync_event.sender().to_owned(),
timestamp: sync_event.origin_server_ts(),
content: reply_content,
})
}
Expand Down
Loading
Loading