matrix-sdk: Add StateChanges::add_notification
parent
f6c4fdde7d
commit
c569436ba4
|
@ -517,24 +517,16 @@ impl BaseClient {
|
||||||
let actions = push_rules.get_actions(&raw_event, &context).to_vec();
|
let actions = push_rules.get_actions(&raw_event, &context).to_vec();
|
||||||
|
|
||||||
if actions.iter().any(|a| matches!(a, Action::Notify)) {
|
if actions.iter().any(|a| matches!(a, Action::Notify)) {
|
||||||
let notification = Notification::new(
|
changes.add_notification(
|
||||||
actions,
|
room_id,
|
||||||
raw_event,
|
Notification::new(
|
||||||
false,
|
actions,
|
||||||
room_id.clone(),
|
raw_event,
|
||||||
SystemTime::now(),
|
false,
|
||||||
|
room_id.clone(),
|
||||||
|
SystemTime::now(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
match changes.notifications.get_mut(room_id) {
|
|
||||||
Some(room) => {
|
|
||||||
room.push(notification);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
changes
|
|
||||||
.notifications
|
|
||||||
.insert(room_id.clone(), vec![notification]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// TODO send and store the highlight tweak value with the event.
|
// TODO send and store the highlight tweak value with the event.
|
||||||
// Needs to associate custom data with events and to store them.
|
// Needs to associate custom data with events and to store them.
|
||||||
|
|
|
@ -442,4 +442,12 @@ impl StateChanges {
|
||||||
.or_insert_with(BTreeMap::new)
|
.or_insert_with(BTreeMap::new)
|
||||||
.insert(event.state_key().to_string(), event);
|
.insert(event.state_key().to_string(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update the `StateChanges` struct with the given room with a new `Notification`.
|
||||||
|
pub fn add_notification(&mut self, room_id: &RoomId, notification: Notification) {
|
||||||
|
self.notifications
|
||||||
|
.entry(room_id.to_owned())
|
||||||
|
.or_insert_with(Vec::new)
|
||||||
|
.push(notification);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue