atagen

macltok

public
Star0
Watch0
8d93a5d23add4d5fcc3b8af5561044099d8729db
3
ssh://brewery@pls.lobotomise.me:33/atagen/macltok.git

Blame: src/normalise/room.rs

96fdf90aacd6atagen2026-09-08 08:24 UTC1
use futures_util::{StreamExt, stream};
31ce2453c82fatagen2026-09-24 13:07 UTC2
use matrix_sdk::{
31ce2453c82fatagen2026-09-24 13:07 UTC3
    Client, Room, RoomState,
31ce2453c82fatagen2026-09-24 13:07 UTC4
    deserialized_responses::SyncOrStrippedState,
31ce2453c82fatagen2026-09-24 13:07 UTC5
    latest_events::LatestEventValue,
31ce2453c82fatagen2026-09-24 13:07 UTC6
    ruma::events::{
fa5b4e09943aatagen2026-10-24 09:33 UTC7
        AnyMessageLikeEventContent, AnySyncMessageLikeEvent, AnySyncTimelineEvent, StateEventType,
fa5b4e09943aatagen2026-10-24 09:33 UTC8
        SyncStateEvent,
5a52012c9b1datagen2026-09-24 23:45 UTC9
        room::message::{Relation, RoomMessageEventContent},
31ce2453c82fatagen2026-09-24 13:07 UTC10
        space::child::SpaceChildEventContent,
31ce2453c82fatagen2026-09-24 13:07 UTC11
    },
31ce2453c82fatagen2026-09-24 13:07 UTC12
};
31ce2453c82fatagen2026-09-24 13:07 UTC13
use matrix_sdk_ui::spaces::{SpaceRoom, SpaceService};
9bd34e25bb86atagen2026-10-24 07:23 UTC14
use ruma::{
9bd34e25bb86atagen2026-10-24 07:23 UTC15
    OwnedRoomId,
9bd34e25bb86atagen2026-10-24 07:23 UTC16
    serde::{JsonObject, Raw},
9bd34e25bb86atagen2026-10-24 07:23 UTC17
};
96fdf90aacd6atagen2026-09-08 08:24 UTC18
5a52012c9b1datagen2026-09-24 23:45 UTC19
use super::message_kind;
31ce2453c82fatagen2026-09-24 13:07 UTC20
use crate::{
5d2974de5826atagen2026-10-08 11:29 UTC21
    LatestEvent, MediaId, MessageKind, RoomHero, RoomMembership, RoomNotificationMode, RoomSummary,
9bd34e25bb86atagen2026-10-24 07:23 UTC22
    SendState, SpaceChild, space_order,
31ce2453c82fatagen2026-09-24 13:07 UTC23
};
96fdf90aacd6atagen2026-09-08 08:24 UTC24
31ce2453c82fatagen2026-09-24 13:07 UTC25
pub(crate) async fn room_summaries(client: &Client, spaces: &SpaceService) -> Vec<RoomSummary> {
96fdf90aacd6atagen2026-09-08 08:24 UTC26
    let mut summaries = stream::iter(client.rooms())
31ce2453c82fatagen2026-09-24 13:07 UTC27
        .map(|room| async move { room_summary(&room, spaces).await })
96fdf90aacd6atagen2026-09-08 08:24 UTC28
        .buffer_unordered(16)
96fdf90aacd6atagen2026-09-08 08:24 UTC29
        .collect::<Vec<_>>()
96fdf90aacd6atagen2026-09-08 08:24 UTC30
        .await;
96fdf90aacd6atagen2026-09-08 08:24 UTC31
    summaries.sort_by(|left, right| {
96fdf90aacd6atagen2026-09-08 08:24 UTC32
        right
96fdf90aacd6atagen2026-09-08 08:24 UTC33
            .latest_event_timestamp_ms
96fdf90aacd6atagen2026-09-08 08:24 UTC34
            .cmp(&left.latest_event_timestamp_ms)
96fdf90aacd6atagen2026-09-08 08:24 UTC35
            .then_with(|| left.name.to_lowercase().cmp(&right.name.to_lowercase()))
96fdf90aacd6atagen2026-09-08 08:24 UTC36
            .then_with(|| left.room_id.cmp(&right.room_id))
96fdf90aacd6atagen2026-09-08 08:24 UTC37
    });
96fdf90aacd6atagen2026-09-08 08:24 UTC38
    summaries
96fdf90aacd6atagen2026-09-08 08:24 UTC39
}
96fdf90aacd6atagen2026-09-08 08:24 UTC40
31ce2453c82fatagen2026-09-24 13:07 UTC41
async fn room_summary(room: &Room, spaces: &SpaceService) -> RoomSummary {
96fdf90aacd6atagen2026-09-08 08:24 UTC42
    let name = room
96fdf90aacd6atagen2026-09-08 08:24 UTC43
        .display_name()
96fdf90aacd6atagen2026-09-08 08:24 UTC44
        .await
96fdf90aacd6atagen2026-09-08 08:24 UTC45
        .map(|name| name.to_string())
96fdf90aacd6atagen2026-09-08 08:24 UTC46
        .unwrap_or_else(|_| room.room_id().to_string());
96fdf90aacd6atagen2026-09-08 08:24 UTC47
    let custom_notification_mode = room.user_defined_notification_mode().await;
96fdf90aacd6atagen2026-09-08 08:24 UTC48
    let effective_notification_mode = match custom_notification_mode {
96fdf90aacd6atagen2026-09-08 08:24 UTC49
        Some(mode) => Some(mode),
96fdf90aacd6atagen2026-09-08 08:24 UTC50
        None => room.notification_mode().await,
96fdf90aacd6atagen2026-09-08 08:24 UTC51
    };
31ce2453c82fatagen2026-09-24 13:07 UTC52
    let inviter = match room.state() {
31ce2453c82fatagen2026-09-24 13:07 UTC53
        RoomState::Invited => room
31ce2453c82fatagen2026-09-24 13:07 UTC54
            .invite_details()
31ce2453c82fatagen2026-09-24 13:07 UTC55
            .await
31ce2453c82fatagen2026-09-24 13:07 UTC56
            .ok()
31ce2453c82fatagen2026-09-24 13:07 UTC57
            .map(|invite| invite.inviter_id),
31ce2453c82fatagen2026-09-24 13:07 UTC58
        _ => None,
31ce2453c82fatagen2026-09-24 13:07 UTC59
    };
31ce2453c82fatagen2026-09-24 13:07 UTC60
    let children = if room.is_space() {
31ce2453c82fatagen2026-09-24 13:07 UTC61
        space_children(room).await
31ce2453c82fatagen2026-09-24 13:07 UTC62
    } else {
31ce2453c82fatagen2026-09-24 13:07 UTC63
        Vec::new()
31ce2453c82fatagen2026-09-24 13:07 UTC64
    };
21b9227729a4atagen2026-10-25 11:03 UTC65
    let thread_unreads = super::stored_thread_unreads(room).await;
96fdf90aacd6atagen2026-09-08 08:24 UTC66
    RoomSummary {
96fdf90aacd6atagen2026-09-08 08:24 UTC67
        room_id: room.room_id().to_owned(),
96fdf90aacd6atagen2026-09-08 08:24 UTC68
        name,
31ce2453c82fatagen2026-09-24 13:07 UTC69
        membership: membership(room.state()),
96fdf90aacd6atagen2026-09-08 08:24 UTC70
        unread_messages: room.num_unread_messages(),
e5c6427adb35atagen2026-10-25 10:23 UTC71
        unread_mentions: room.num_unread_mentions()
e5c6427adb35atagen2026-10-25 10:23 UTC72
            + thread_unreads
e5c6427adb35atagen2026-10-25 10:23 UTC73
                .values()
e5c6427adb35atagen2026-10-25 10:23 UTC74
                .map(|unread| unread.mentions)
e5c6427adb35atagen2026-10-25 10:23 UTC75
                .sum::<u64>(),
5a52012c9b1datagen2026-09-24 23:45 UTC76
        unread_notifications: room.num_unread_notifications(),
e5c6427adb35atagen2026-10-25 10:23 UTC77
        thread_unreads,
96fdf90aacd6atagen2026-09-08 08:24 UTC78
        encrypted: room.encryption_state().is_encrypted(),
96fdf90aacd6atagen2026-09-08 08:24 UTC79
        space: room.is_space(),
96fdf90aacd6atagen2026-09-08 08:24 UTC80
        direct: room.is_direct().await.unwrap_or(false),
96fdf90aacd6atagen2026-09-08 08:24 UTC81
        favourite: room.is_favourite(),
96fdf90aacd6atagen2026-09-08 08:24 UTC82
        low_priority: room.is_low_priority(),
5d2974de5826atagen2026-10-08 11:29 UTC83
        avatar: room.avatar_url().as_deref().map(MediaId::plain),
96fdf90aacd6atagen2026-09-08 08:24 UTC84
        latest_event_timestamp_ms: room
96fdf90aacd6atagen2026-09-08 08:24 UTC85
            .latest_event_timestamp()
96fdf90aacd6atagen2026-09-08 08:24 UTC86
            .map(|value| value.get().into()),
31ce2453c82fatagen2026-09-24 13:07 UTC87
        latest_event: latest_event(room),
96fdf90aacd6atagen2026-09-08 08:24 UTC88
        notification_mode: effective_notification_mode.map(notification_mode),
96fdf90aacd6atagen2026-09-08 08:24 UTC89
        notification_mode_custom: custom_notification_mode.is_some(),
31ce2453c82fatagen2026-09-24 13:07 UTC90
        topic: room.topic(),
31ce2453c82fatagen2026-09-24 13:07 UTC91
        canonical_alias: room.canonical_alias(),
31ce2453c82fatagen2026-09-24 13:07 UTC92
        joined_members: room.joined_members_count(),
31ce2453c82fatagen2026-09-24 13:07 UTC93
        invited_members: room.invited_members_count(),
31ce2453c82fatagen2026-09-24 13:07 UTC94
        heroes: room
31ce2453c82fatagen2026-09-24 13:07 UTC95
            .heroes()
31ce2453c82fatagen2026-09-24 13:07 UTC96
            .into_iter()
31ce2453c82fatagen2026-09-24 13:07 UTC97
            .map(|hero| RoomHero {
31ce2453c82fatagen2026-09-24 13:07 UTC98
                user_id: hero.user_id,
31ce2453c82fatagen2026-09-24 13:07 UTC99
                display_name: hero.display_name,
5d2974de5826atagen2026-10-08 11:29 UTC100
                avatar: hero.avatar_url.as_deref().map(MediaId::plain),
31ce2453c82fatagen2026-09-24 13:07 UTC101
            })
31ce2453c82fatagen2026-09-24 13:07 UTC102
            .collect(),
31ce2453c82fatagen2026-09-24 13:07 UTC103
        successor: room.successor_room().map(|successor| successor.room_id),
31ce2453c82fatagen2026-09-24 13:07 UTC104
        inviter,
31ce2453c82fatagen2026-09-24 13:07 UTC105
        parent_spaces: spaces
31ce2453c82fatagen2026-09-24 13:07 UTC106
            .joined_parents_of_child(room.room_id())
31ce2453c82fatagen2026-09-24 13:07 UTC107
            .await
31ce2453c82fatagen2026-09-24 13:07 UTC108
            .into_iter()
31ce2453c82fatagen2026-09-24 13:07 UTC109
            .map(|parent| parent.room_id)
31ce2453c82fatagen2026-09-24 13:07 UTC110
            .collect(),
31ce2453c82fatagen2026-09-24 13:07 UTC111
        children,
9bd34e25bb86atagen2026-10-24 07:23 UTC112
        space_order: if room.is_space() {
9bd34e25bb86atagen2026-10-24 07:23 UTC113
            stored_space_order(room).await
9bd34e25bb86atagen2026-10-24 07:23 UTC114
        } else {
9bd34e25bb86atagen2026-10-24 07:23 UTC115
            None
9bd34e25bb86atagen2026-10-24 07:23 UTC116
        },
fa51490b6ae9atagen2026-10-24 08:41 UTC117
        can_edit_packs: super::can_edit_packs(room).await,
fa5b4e09943aatagen2026-10-24 09:33 UTC118
        pinned_events: room.pinned_event_ids().unwrap_or_default(),
fa5b4e09943aatagen2026-10-24 09:33 UTC119
        can_pin: room.state() == RoomState::Joined
fa5b4e09943aatagen2026-10-24 09:33 UTC120
            && room.power_levels().await.is_ok_and(|levels| {
fa5b4e09943aatagen2026-10-24 09:33 UTC121
                levels.user_can_send_state(room.own_user_id(), StateEventType::RoomPinnedEvents)
fa5b4e09943aatagen2026-10-24 09:33 UTC122
            }),
31ce2453c82fatagen2026-09-24 13:07 UTC123
    }
31ce2453c82fatagen2026-09-24 13:07 UTC124
}
31ce2453c82fatagen2026-09-24 13:07 UTC125
9bd34e25bb86atagen2026-10-24 07:23 UTC126
/// None when unset or when another client wrote something msc3230 doesn't allow
9bd34e25bb86atagen2026-10-24 07:23 UTC127
pub(crate) async fn stored_space_order(room: &Room) -> Option<String> {
9bd34e25bb86atagen2026-10-24 07:23 UTC128
    room.account_data(space_order::EVENT_TYPE.into())
9bd34e25bb86atagen2026-10-24 07:23 UTC129
        .await
9bd34e25bb86atagen2026-10-24 07:23 UTC130
        .ok()??
9bd34e25bb86atagen2026-10-24 07:23 UTC131
        .get_field::<Raw<JsonObject>>("content")
9bd34e25bb86atagen2026-10-24 07:23 UTC132
        .ok()??
9bd34e25bb86atagen2026-10-24 07:23 UTC133
        .get_field::<String>("order")
9bd34e25bb86atagen2026-10-24 07:23 UTC134
        .ok()?
9bd34e25bb86atagen2026-10-24 07:23 UTC135
        .filter(|order| space_order::valid(order))
9bd34e25bb86atagen2026-10-24 07:23 UTC136
}
9bd34e25bb86atagen2026-10-24 07:23 UTC137
31ce2453c82fatagen2026-09-24 13:07 UTC138
const fn membership(state: RoomState) -> RoomMembership {
31ce2453c82fatagen2026-09-24 13:07 UTC139
    match state {
31ce2453c82fatagen2026-09-24 13:07 UTC140
        RoomState::Joined => RoomMembership::Joined,
31ce2453c82fatagen2026-09-24 13:07 UTC141
        RoomState::Invited => RoomMembership::Invited,
31ce2453c82fatagen2026-09-24 13:07 UTC142
        RoomState::Left => RoomMembership::Left,
31ce2453c82fatagen2026-09-24 13:07 UTC143
        RoomState::Knocked => RoomMembership::Knocked,
31ce2453c82fatagen2026-09-24 13:07 UTC144
        RoomState::Banned => RoomMembership::Banned,
31ce2453c82fatagen2026-09-24 13:07 UTC145
    }
31ce2453c82fatagen2026-09-24 13:07 UTC146
}
31ce2453c82fatagen2026-09-24 13:07 UTC147
31ce2453c82fatagen2026-09-24 13:07 UTC148
/// what the space itself lists, straight from local state. redacted children don't count
31ce2453c82fatagen2026-09-24 13:07 UTC149
async fn space_children(room: &Room) -> Vec<OwnedRoomId> {
31ce2453c82fatagen2026-09-24 13:07 UTC150
    let Ok(events) = room
31ce2453c82fatagen2026-09-24 13:07 UTC151
        .get_state_events_static::<SpaceChildEventContent>()
31ce2453c82fatagen2026-09-24 13:07 UTC152
        .await
31ce2453c82fatagen2026-09-24 13:07 UTC153
    else {
31ce2453c82fatagen2026-09-24 13:07 UTC154
        return Vec::new();
31ce2453c82fatagen2026-09-24 13:07 UTC155
    };
31ce2453c82fatagen2026-09-24 13:07 UTC156
    events
31ce2453c82fatagen2026-09-24 13:07 UTC157
        .into_iter()
31ce2453c82fatagen2026-09-24 13:07 UTC158
        .filter_map(|event| match event.deserialize().ok()? {
31ce2453c82fatagen2026-09-24 13:07 UTC159
            SyncOrStrippedState::Sync(SyncStateEvent::Original(event)) => Some(event.state_key),
31ce2453c82fatagen2026-09-24 13:07 UTC160
            SyncOrStrippedState::Stripped(event) => Some(event.state_key),
31ce2453c82fatagen2026-09-24 13:07 UTC161
            SyncOrStrippedState::Sync(SyncStateEvent::Redacted(_)) => None,
31ce2453c82fatagen2026-09-24 13:07 UTC162
        })
31ce2453c82fatagen2026-09-24 13:07 UTC163
        .collect()
31ce2453c82fatagen2026-09-24 13:07 UTC164
}
31ce2453c82fatagen2026-09-24 13:07 UTC165
31ce2453c82fatagen2026-09-24 13:07 UTC166
fn latest_event(room: &Room) -> Option<LatestEvent> {
5a52012c9b1datagen2026-09-24 23:45 UTC167
    let own = || Some(room.own_user_id().to_owned());
5a52012c9b1datagen2026-09-24 23:45 UTC168
    let local = |local: &matrix_sdk::latest_events::LocalLatestEventValue| {
5a52012c9b1datagen2026-09-24 23:45 UTC169
        let preview = match local.content.deserialize() {
5a52012c9b1datagen2026-09-24 23:45 UTC170
            Ok(AnyMessageLikeEventContent::RoomMessage(content)) => preview(&content),
5a52012c9b1datagen2026-09-24 23:45 UTC171
            _ => (None, None),
5a52012c9b1datagen2026-09-24 23:45 UTC172
        };
5a52012c9b1datagen2026-09-24 23:45 UTC173
        (preview, Some(local.timestamp))
5a52012c9b1datagen2026-09-24 23:45 UTC174
    };
5a52012c9b1datagen2026-09-24 23:45 UTC175
    let (sender, (kind, body), timestamp, send_state) = match room.latest_event() {
31ce2453c82fatagen2026-09-24 13:07 UTC176
        LatestEventValue::None => return None,
31ce2453c82fatagen2026-09-24 13:07 UTC177
        LatestEventValue::Remote(event) => {
5a52012c9b1datagen2026-09-24 23:45 UTC178
            let preview = match event.raw().deserialize() {
31ce2453c82fatagen2026-09-24 13:07 UTC179
                Ok(AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::RoomMessage(
31ce2453c82fatagen2026-09-24 13:07 UTC180
                    message,
31ce2453c82fatagen2026-09-24 13:07 UTC181
                ))) => message
31ce2453c82fatagen2026-09-24 13:07 UTC182
                    .as_original()
5a52012c9b1datagen2026-09-24 23:45 UTC183
                    .map_or((None, None), |message| preview(&message.content)),
5a52012c9b1datagen2026-09-24 23:45 UTC184
                _ => (None, None),
31ce2453c82fatagen2026-09-24 13:07 UTC185
            };
5a52012c9b1datagen2026-09-24 23:45 UTC186
            (event.sender(), preview, event.timestamp(), SendState::Sent)
31ce2453c82fatagen2026-09-24 13:07 UTC187
        }
31ce2453c82fatagen2026-09-24 13:07 UTC188
        LatestEventValue::RemoteInvite {
31ce2453c82fatagen2026-09-24 13:07 UTC189
            timestamp, inviter, ..
5a52012c9b1datagen2026-09-24 23:45 UTC190
        } => (inviter, (None, None), Some(timestamp), SendState::Sent),
5a52012c9b1datagen2026-09-24 23:45 UTC191
        LatestEventValue::LocalIsSending(value) => {
5a52012c9b1datagen2026-09-24 23:45 UTC192
            let (preview, timestamp) = local(&value);
5a52012c9b1datagen2026-09-24 23:45 UTC193
            (own(), preview, timestamp, SendState::Sending)
5a52012c9b1datagen2026-09-24 23:45 UTC194
        }
31ce2453c82fatagen2026-09-24 13:07 UTC195
        LatestEventValue::LocalHasBeenSent { value, .. } => {
5a52012c9b1datagen2026-09-24 23:45 UTC196
            let (preview, timestamp) = local(&value);
5a52012c9b1datagen2026-09-24 23:45 UTC197
            (own(), preview, timestamp, SendState::Sent)
31ce2453c82fatagen2026-09-24 13:07 UTC198
        }
5a52012c9b1datagen2026-09-24 23:45 UTC199
        // the sdk won't say whether it'll retry, so assume the user has to
5a52012c9b1datagen2026-09-24 23:45 UTC200
        LatestEventValue::LocalCannotBeSent(value) => {
5a52012c9b1datagen2026-09-24 23:45 UTC201
            let (preview, timestamp) = local(&value);
5a52012c9b1datagen2026-09-24 23:45 UTC202
            (
5a52012c9b1datagen2026-09-24 23:45 UTC203
                own(),
5a52012c9b1datagen2026-09-24 23:45 UTC204
                preview,
5a52012c9b1datagen2026-09-24 23:45 UTC205
                timestamp,
5a52012c9b1datagen2026-09-24 23:45 UTC206
                SendState::Failed { will_retry: false },
5a52012c9b1datagen2026-09-24 23:45 UTC207
            )
31ce2453c82fatagen2026-09-24 13:07 UTC208
        }
31ce2453c82fatagen2026-09-24 13:07 UTC209
    };
31ce2453c82fatagen2026-09-24 13:07 UTC210
    Some(LatestEvent {
31ce2453c82fatagen2026-09-24 13:07 UTC211
        sender,
5a52012c9b1datagen2026-09-24 23:45 UTC212
        kind,
31ce2453c82fatagen2026-09-24 13:07 UTC213
        body,
31ce2453c82fatagen2026-09-24 13:07 UTC214
        timestamp_ms: timestamp.map(|timestamp| timestamp.get().into()),
31ce2453c82fatagen2026-09-24 13:07 UTC215
        send_state,
31ce2453c82fatagen2026-09-24 13:07 UTC216
    })
31ce2453c82fatagen2026-09-24 13:07 UTC217
}
31ce2453c82fatagen2026-09-24 13:07 UTC218
5a52012c9b1datagen2026-09-24 23:45 UTC219
/// the latest event of an edited message is the edit, whose own body is the `* fallback`
5a52012c9b1datagen2026-09-24 23:45 UTC220
fn preview(content: &RoomMessageEventContent) -> (Option<MessageKind>, Option<String>) {
5a52012c9b1datagen2026-09-24 23:45 UTC221
    let msgtype = match &content.relates_to {
5a52012c9b1datagen2026-09-24 23:45 UTC222
        Some(Relation::Replacement(replacement)) => &replacement.new_content.msgtype,
5a52012c9b1datagen2026-09-24 23:45 UTC223
        _ => &content.msgtype,
31ce2453c82fatagen2026-09-24 13:07 UTC224
    };
5a52012c9b1datagen2026-09-24 23:45 UTC225
    (Some(message_kind(msgtype)), Some(msgtype.body().to_owned()))
31ce2453c82fatagen2026-09-24 13:07 UTC226
}
31ce2453c82fatagen2026-09-24 13:07 UTC227
31ce2453c82fatagen2026-09-24 13:07 UTC228
pub(crate) fn space_child(room: SpaceRoom) -> SpaceChild {
31ce2453c82fatagen2026-09-24 13:07 UTC229
    SpaceChild {
31ce2453c82fatagen2026-09-24 13:07 UTC230
        name: room.display_name,
31ce2453c82fatagen2026-09-24 13:07 UTC231
        room_id: room.room_id,
31ce2453c82fatagen2026-09-24 13:07 UTC232
        topic: room.topic,
5d2974de5826atagen2026-10-08 11:29 UTC233
        avatar: room.avatar_url.as_deref().map(MediaId::plain),
31ce2453c82fatagen2026-09-24 13:07 UTC234
        canonical_alias: room.canonical_alias,
31ce2453c82fatagen2026-09-24 13:07 UTC235
        joined_members: room.num_joined_members,
31ce2453c82fatagen2026-09-24 13:07 UTC236
        space: room.room_type == Some(ruma::room::RoomType::Space),
31ce2453c82fatagen2026-09-24 13:07 UTC237
        children_count: room.children_count,
31ce2453c82fatagen2026-09-24 13:07 UTC238
        membership: room.state.map(membership),
31ce2453c82fatagen2026-09-24 13:07 UTC239
        via: room.via,
31ce2453c82fatagen2026-09-24 13:07 UTC240
        suggested: room.suggested,
31ce2453c82fatagen2026-09-24 13:07 UTC241
        world_readable: room.world_readable,
31ce2453c82fatagen2026-09-24 13:07 UTC242
        guest_can_join: room.guest_can_join,
96fdf90aacd6atagen2026-09-08 08:24 UTC243
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC244
}
96fdf90aacd6atagen2026-09-08 08:24 UTC245
96fdf90aacd6atagen2026-09-08 08:24 UTC246
pub(crate) const fn notification_mode(
96fdf90aacd6atagen2026-09-08 08:24 UTC247
    mode: matrix_sdk::notification_settings::RoomNotificationMode,
96fdf90aacd6atagen2026-09-08 08:24 UTC248
) -> RoomNotificationMode {
96fdf90aacd6atagen2026-09-08 08:24 UTC249
    match mode {
96fdf90aacd6atagen2026-09-08 08:24 UTC250
        matrix_sdk::notification_settings::RoomNotificationMode::AllMessages => {
96fdf90aacd6atagen2026-09-08 08:24 UTC251
            RoomNotificationMode::AllMessages
96fdf90aacd6atagen2026-09-08 08:24 UTC252
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC253
        matrix_sdk::notification_settings::RoomNotificationMode::MentionsAndKeywordsOnly => {
96fdf90aacd6atagen2026-09-08 08:24 UTC254
            RoomNotificationMode::MentionsAndKeywordsOnly
96fdf90aacd6atagen2026-09-08 08:24 UTC255
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC256
        matrix_sdk::notification_settings::RoomNotificationMode::Mute => RoomNotificationMode::Mute,
96fdf90aacd6atagen2026-09-08 08:24 UTC257
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC258
}