Skip to content

Commit 8e2453a

Browse files
committed
feat: expose call_intent for m.rtc.notification
This allows for notifications to use the intent for deciding how to render the message (e.g. whether to call it a "call" or a "video call"). Signed-off-by: Bryant Mairs <bryant@mai.rs>
1 parent a65fec3 commit 8e2453a

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

bindings/matrix-sdk-ffi/src/timeline/content.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ impl From<matrix_sdk_ui::timeline::TimelineItemContent> for TimelineItemContent
4040

4141
Content::CallInvite => TimelineItemContent::CallInvite,
4242

43-
Content::RtcNotification => TimelineItemContent::RtcNotification,
43+
Content::RtcNotification { call_intent } => TimelineItemContent::RtcNotification {
44+
call_intent: call_intent.map(|s| s.to_string()),
45+
},
4446

4547
Content::MembershipChange(membership) => {
4648
let reason = match membership.content() {
@@ -159,7 +161,9 @@ pub enum TimelineItemContent {
159161
content: MsgLikeContent,
160162
},
161163
CallInvite,
162-
RtcNotification,
164+
RtcNotification {
165+
call_intent: Option<String>,
166+
},
163167
RoomMembership {
164168
user_id: String,
165169
user_display_name: Option<String>,

crates/matrix-sdk-ui/CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ All notable changes to this project will be documented in this file.
3030

3131
### Features
3232

33+
- Add `call_intent` to `TimelineItemContent::RtcNotification`
34+
([#6412](https://github.com/matrix-org/matrix-rust-sdk/pull/6412))
3335
- Introduce a `ThreadListService` which offers reactive interfaces for rendering
3436
and managing the list of threads from a particular room.
35-
([6311](https://github.com/matrix-org/matrix-rust-sdk/pull/6311))
37+
([#6311](https://github.com/matrix-org/matrix-rust-sdk/pull/6311))
3638
- [**breaking**] Remove the `Room::load_thread_list` in favor of the new `ThreadListService`
37-
([6311](https://github.com/matrix-org/matrix-rust-sdk/pull/6311))
38-
- Add support for [MSC3489](https://github.com/matrix-org/matrix-spec-proposals/pull/3489)
39+
([#6311](https://github.com/matrix-org/matrix-rust-sdk/pull/6311))
40+
- Add support for [MSC3489](https://github.com/matrix-org/matrix-spec-proposals/pull/3489)
3941
live location sharing through a new `TimelineItemContent::LiveLocation` variant.
4042
- The internal timeline unique ID may be recycled when an event is deduplicated from the timeline,
4143
so that embedders can notice that it's the same item and avoid unnecessary re-rendering.

crates/matrix-sdk-ui/src/timeline/event_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ impl TimelineAction {
411411
Self::add_item(TimelineItemContent::CallInvite)
412412
}
413413

414-
AnyMessageLikeEventContent::RtcNotification(_) => {
415-
Self::add_item(TimelineItemContent::RtcNotification)
414+
AnyMessageLikeEventContent::RtcNotification(c) => {
415+
Self::add_item(TimelineItemContent::RtcNotification { call_intent: c.call_intent })
416416
}
417417

418418
AnyMessageLikeEventContent::Sticker(content) => {

crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use ruma::{
4747
tombstone::RoomTombstoneEventContent,
4848
topic::RoomTopicEventContent,
4949
},
50+
rtc::notification::CallIntent,
5051
space::{child::SpaceChildEventContent, parent::SpaceParentEventContent},
5152
sticker::StickerEventContent,
5253
},
@@ -121,7 +122,10 @@ pub enum TimelineItemContent {
121122
CallInvite,
122123

123124
/// An `m.rtc.notification` event
124-
RtcNotification,
125+
RtcNotification {
126+
/// The intent of this notification.
127+
call_intent: Option<CallIntent>,
128+
},
125129
}
126130

127131
impl TimelineItemContent {
@@ -146,7 +150,7 @@ impl TimelineItemContent {
146150
Self::FailedToParseMessageLike { event_type, .. } => Some(event_type.to_string()),
147151
Self::FailedToParseState { event_type, .. } => Some(event_type.to_string()),
148152
Self::CallInvite => Some(MessageLikeEventType::CallInvite.to_string()),
149-
Self::RtcNotification => Some(MessageLikeEventType::RtcNotification.to_string()),
153+
Self::RtcNotification { .. } => Some(MessageLikeEventType::RtcNotification.to_string()),
150154
}
151155
}
152156

@@ -330,7 +334,7 @@ impl TimelineItemContent {
330334
TimelineItemContent::FailedToParseMessageLike { .. }
331335
| TimelineItemContent::FailedToParseState { .. } => "an event that couldn't be parsed",
332336
TimelineItemContent::CallInvite => "a call invite",
333-
TimelineItemContent::RtcNotification => "a call notification",
337+
TimelineItemContent::RtcNotification { .. } => "a call notification",
334338
}
335339
}
336340

@@ -401,7 +405,7 @@ impl TimelineItemContent {
401405

402406
pub(in crate::timeline) fn redact(&self, rules: &RedactionRules) -> Self {
403407
match self {
404-
Self::MsgLike(_) | Self::CallInvite | Self::RtcNotification => {
408+
Self::MsgLike(_) | Self::CallInvite | Self::RtcNotification { .. } => {
405409
TimelineItemContent::MsgLike(MsgLikeContent::redacted())
406410
}
407411
Self::MembershipChange(ev) => Self::MembershipChange(ev.redact(rules)),
@@ -433,7 +437,7 @@ impl TimelineItemContent {
433437
| TimelineItemContent::FailedToParseMessageLike { .. }
434438
| TimelineItemContent::FailedToParseState { .. }
435439
| TimelineItemContent::CallInvite
436-
| TimelineItemContent::RtcNotification => {
440+
| TimelineItemContent::RtcNotification { .. } => {
437441
// No reactions for these kind of items.
438442
None
439443
}
@@ -458,7 +462,7 @@ impl TimelineItemContent {
458462
| TimelineItemContent::FailedToParseMessageLike { .. }
459463
| TimelineItemContent::FailedToParseState { .. }
460464
| TimelineItemContent::CallInvite
461-
| TimelineItemContent::RtcNotification => {
465+
| TimelineItemContent::RtcNotification { .. } => {
462466
// No reactions for these kind of items.
463467
None
464468
}

crates/matrix-sdk-ui/src/timeline/event_item/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl EventTimelineItem {
593593
| TimelineItemContent::FailedToParseMessageLike { .. }
594594
| TimelineItemContent::FailedToParseState { .. }
595595
| TimelineItemContent::CallInvite
596-
| TimelineItemContent::RtcNotification => None,
596+
| TimelineItemContent::RtcNotification { .. } => None,
597597
};
598598

599599
if let Some(body) = body {

labs/multiverse/src/widgets/room_view/timeline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn format_timeline_item(item: &Arc<TimelineItem>, is_thread: bool) -> Option<Lis
139139
kind: MsgLikeKind::Poll(_), ..
140140
})
141141
| TimelineItemContent::CallInvite
142-
| TimelineItemContent::RtcNotification => {
142+
| TimelineItemContent::RtcNotification { .. } => {
143143
return None;
144144
}
145145

0 commit comments

Comments
 (0)