Skip to content

Commit 96d0a90

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 96d0a90

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,10 @@ 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 {
416+
call_intent: c.call_intent
417+
})
416418
}
417419

418420
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 {

0 commit comments

Comments
 (0)