feat(sdk): Remove LocalEventTimelineItem.encryption_info and .raw, and Remote….raw is no more an Option.

This commit is contained in:
Ivan Enderlin
2023-01-30 08:49:48 +01:00
parent 17a9c4829d
commit 322aa776f2
4 changed files with 18 additions and 35 deletions

View File

@@ -512,32 +512,29 @@ impl<'a, 'i> TimelineEventHandler<'a, 'i> {
let item = {
let sender = self.meta.sender.to_owned();
let sender_profile = self.meta.sender_profile.clone();
let timestamp = self.flow.timestamp();
let encryption_info = self.meta.encryption_info.clone();
let raw = self.flow.raw_event().cloned();
match &self.flow {
Flow::Local { txn_id, .. } => EventTimelineItem::Local(LocalEventTimelineItem {
transaction_id: txn_id.to_owned(),
event_id: None,
sender,
sender_profile,
timestamp,
content,
encryption_info,
raw,
}),
Flow::Remote { event_id, .. } => {
Flow::Local { txn_id, timestamp } => {
EventTimelineItem::Local(LocalEventTimelineItem {
transaction_id: txn_id.to_owned(),
event_id: None,
sender,
sender_profile,
timestamp: *timestamp,
content,
})
}
Flow::Remote { event_id, origin_server_ts, raw_event, .. } => {
EventTimelineItem::Remote(RemoteEventTimelineItem {
event_id: event_id.clone(),
sender,
sender_profile,
timestamp,
timestamp: *origin_server_ts,
content,
reactions,
is_own: self.meta.is_own_event,
encryption_info,
raw,
encryption_info: self.meta.encryption_info.clone(),
raw: raw_event.clone(),
})
}
}

View File

@@ -161,9 +161,9 @@ impl EventTimelineItem {
/// Returns `None` if this event hasn't been echoed back by the server
/// yet.
pub fn raw(&self) -> Option<&Raw<AnySyncTimelineEvent>> {
match self {
Self::Local(local_event) => local_event.raw.as_ref(),
Self::Remote(remote_event) => remote_event.raw.as_ref(),
match &self {
Self::Local(local_event) => None,
Self::Remote(ref remote_event) => Some(&remote_event.raw),
}
}
@@ -194,10 +194,6 @@ pub struct LocalEventTimelineItem {
pub timestamp: MilliSecondsSinceUnixEpoch,
/// The content of the event.
pub content: TimelineItemContent,
/// Encryption information.
pub encryption_info: Option<EncryptionInfo>,
// FIXME: Expose the raw JSON of aggregated events somehow
pub raw: Option<Raw<AnySyncTimelineEvent>>,
}
impl LocalEventTimelineItem {
@@ -221,8 +217,6 @@ impl fmt::Debug for LocalEventTimelineItem {
.field("sender", &self.sender)
.field("timestamp", &self.timestamp)
.field("content", &self.content)
.field("encryption_info", &self.encryption_info)
// skip raw, too noisy
.finish_non_exhaustive()
}
}
@@ -246,7 +240,7 @@ pub struct RemoteEventTimelineItem {
/// Encryption information.
pub encryption_info: Option<EncryptionInfo>,
// FIXME: Expose the raw JSON of aggregated events somehow
pub raw: Option<Raw<AnySyncTimelineEvent>>,
pub raw: Raw<AnySyncTimelineEvent>,
}
impl RemoteEventTimelineItem {

View File

@@ -258,11 +258,6 @@ impl<P: ProfileProvider> TimelineInner<P> {
return None;
};
let Some(raw) = raw else {
error!("No raw event in unable-to-decrypt timeline item");
return None;
};
Some((
idx,
event_id.to_owned(),

View File

@@ -188,7 +188,6 @@ async fn echo() {
assert_matches!(timeline_stream.next().await, Some(VecDiff::Push { value }) => value);
let item = local_echo.as_event().unwrap().as_local().unwrap();
assert!(item.event_id.is_none());
assert!(item.raw.is_none());
let msg = assert_matches!(item.content, TimelineItemContent::Message(ref msg) => msg);
let text = assert_matches!(msg.msgtype(), MessageType::Text(text) => text);
@@ -203,7 +202,6 @@ async fn echo() {
);
let item = sent_confirmation.as_event().unwrap().as_local().unwrap();
assert!(item.event_id.is_some());
assert!(item.raw.is_none());
ev_builder.add_joined_room(JoinedRoomBuilder::new(room_id).add_timeline_event(
TimelineTestEvent::Custom(json!({
@@ -235,7 +233,6 @@ async fn echo() {
let item = remote_echo.as_event().unwrap().as_remote().unwrap();
assert!(item.is_own);
assert_eq!(item.timestamp, MilliSecondsSinceUnixEpoch(uint!(152038280)));
assert_matches!(item.raw, Some(_));
}
#[async_test]