mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 15:04:11 -04:00
sdk: Add more data to RemoteEventTimelineItem Debug string
This commit is contained in:
committed by
Jonas Platte
parent
5d94a5d2f4
commit
7d5908beef
@@ -44,8 +44,8 @@ use tracing::{debug, error, field::debug, info, instrument, trace, warn};
|
||||
use super::{
|
||||
event_item::{
|
||||
AnyOtherFullStateEventContent, BundledReactions, EventSendState, EventTimelineItemKind,
|
||||
LocalEventTimelineItem, MemberProfileChange, OtherState, Profile, RemoteEventTimelineItem,
|
||||
RoomMembershipChange, Sticker,
|
||||
LocalEventTimelineItem, MemberProfileChange, OtherState, Profile, RemoteEventOrigin,
|
||||
RemoteEventTimelineItem, RoomMembershipChange, Sticker,
|
||||
},
|
||||
find_read_marker,
|
||||
read_receipts::maybe_add_implicit_read_receipt,
|
||||
@@ -558,7 +558,7 @@ impl<'a> TimelineEventHandler<'a> {
|
||||
LocalEventTimelineItem { send_state, transaction_id }
|
||||
}
|
||||
.into(),
|
||||
Flow::Remote { event_id, raw_event, .. } => {
|
||||
Flow::Remote { event_id, raw_event, position, .. } => {
|
||||
// Drop pending reactions if the message is redacted.
|
||||
if let TimelineItemContent::RedactedMessage = content {
|
||||
if !reactions.is_empty() {
|
||||
@@ -566,15 +566,30 @@ impl<'a> TimelineEventHandler<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
let origin = match position {
|
||||
TimelineItemPosition::Start => RemoteEventOrigin::Pagination,
|
||||
// We only paginate backwards for now, so End only happens for syncs
|
||||
TimelineItemPosition::End => RemoteEventOrigin::Sync,
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
TimelineItemPosition::Update(idx) => self.items[*idx]
|
||||
.as_event()
|
||||
.and_then(|ev| Some(ev.as_remote()?.origin))
|
||||
.unwrap_or_else(|| {
|
||||
error!("Decryption retried on a local event");
|
||||
RemoteEventOrigin::Unknown
|
||||
}),
|
||||
};
|
||||
|
||||
RemoteEventTimelineItem {
|
||||
event_id: event_id.clone(),
|
||||
reactions,
|
||||
read_receipts: self.meta.read_receipts.clone(),
|
||||
is_own: self.meta.is_own_event,
|
||||
is_highlighted: self.meta.is_highlighted,
|
||||
encryption_info: self.meta.encryption_info.clone(),
|
||||
original_json: raw_event.clone(),
|
||||
latest_edit_json: None,
|
||||
is_highlighted: self.meta.is_highlighted,
|
||||
origin,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ pub use self::content::{
|
||||
MemberProfileChange, MembershipChange, Message, OtherState, ReactionGroup, RepliedToEvent,
|
||||
RoomMembershipChange, Sticker, TimelineItemContent,
|
||||
};
|
||||
pub(super) use self::{local::LocalEventTimelineItem, remote::RemoteEventTimelineItem};
|
||||
pub(super) use self::{
|
||||
local::LocalEventTimelineItem,
|
||||
remote::{RemoteEventOrigin, RemoteEventTimelineItem},
|
||||
};
|
||||
|
||||
/// An item in the timeline that represents at least one event.
|
||||
///
|
||||
|
||||
@@ -26,6 +26,8 @@ pub(in crate::room::timeline) struct RemoteEventTimelineItem {
|
||||
pub read_receipts: IndexMap<OwnedUserId, Receipt>,
|
||||
/// Whether the event has been sent by the the logged-in user themselves.
|
||||
pub is_own: bool,
|
||||
/// Whether the item should be highlighted in the timeline.
|
||||
pub is_highlighted: bool,
|
||||
/// Encryption information.
|
||||
pub encryption_info: Option<EncryptionInfo>,
|
||||
/// JSON of the original event.
|
||||
@@ -35,8 +37,8 @@ pub(in crate::room::timeline) struct RemoteEventTimelineItem {
|
||||
pub original_json: Raw<AnySyncTimelineEvent>,
|
||||
/// JSON of the latest edit to this item.
|
||||
pub latest_edit_json: Option<Raw<AnySyncTimelineEvent>>,
|
||||
/// Whether the item should be highlighted in the timeline.
|
||||
pub is_highlighted: bool,
|
||||
/// Where we got this event from: A sync response or pagination.
|
||||
pub origin: RemoteEventOrigin,
|
||||
}
|
||||
|
||||
impl RemoteEventTimelineItem {
|
||||
@@ -63,15 +65,42 @@ impl RemoteEventTimelineItem {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where we got an event from.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(in crate::room::timeline) enum RemoteEventOrigin {
|
||||
/// The event came from a sync response.
|
||||
Sync,
|
||||
/// The event came from pagination.
|
||||
Pagination,
|
||||
/// We don't know.
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
impl fmt::Debug for RemoteEventTimelineItem {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// skip raw JSON, too noisy
|
||||
let Self {
|
||||
event_id,
|
||||
reactions,
|
||||
read_receipts,
|
||||
is_own,
|
||||
encryption_info,
|
||||
original_json: _,
|
||||
latest_edit_json: _,
|
||||
is_highlighted,
|
||||
origin,
|
||||
} = self;
|
||||
|
||||
f.debug_struct("RemoteEventTimelineItem")
|
||||
.field("event_id", &self.event_id)
|
||||
.field("reactions", &self.reactions)
|
||||
.field("is_own", &self.is_own)
|
||||
.field("encryption_info", &self.encryption_info)
|
||||
// skip raw, too noisy
|
||||
.field("event_id", event_id)
|
||||
.field("reactions", reactions)
|
||||
.field("read_receipts", read_receipts)
|
||||
.field("is_own", is_own)
|
||||
.field("is_highlighted", is_highlighted)
|
||||
.field("encryption_info", encryption_info)
|
||||
.field("origin", origin)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user