Remove contact notifications when cancelling a contact request
This commit is contained in:
parent
39e3ddb080
commit
83fb8d20b7
10 changed files with 224 additions and 87 deletions
|
@ -177,7 +177,8 @@ message Envelope {
|
|||
|
||||
NewNotification new_notification = 148;
|
||||
GetNotifications get_notifications = 149;
|
||||
GetNotificationsResponse get_notifications_response = 150; // Current max
|
||||
GetNotificationsResponse get_notifications_response = 150;
|
||||
DeleteNotification delete_notification = 151; // Current max
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1590,6 +1591,10 @@ message GetNotificationsResponse {
|
|||
repeated Notification notifications = 1;
|
||||
}
|
||||
|
||||
message DeleteNotification {
|
||||
uint64 notification_id = 1;
|
||||
}
|
||||
|
||||
message Notification {
|
||||
uint64 id = 1;
|
||||
uint64 timestamp = 2;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use serde_json::{map, Value};
|
||||
use std::borrow::Cow;
|
||||
use strum::{EnumVariantNames, IntoStaticStr, VariantNames as _};
|
||||
|
||||
|
@ -47,10 +47,12 @@ impl Notification {
|
|||
let mut value = serde_json::to_value(self).unwrap();
|
||||
let mut actor_id = None;
|
||||
if let Some(value) = value.as_object_mut() {
|
||||
value.remove("kind");
|
||||
actor_id = value
|
||||
.remove("actor_id")
|
||||
.and_then(|value| Some(value.as_i64()? as u64));
|
||||
value.remove(KIND);
|
||||
if let map::Entry::Occupied(e) = value.entry(ACTOR_ID) {
|
||||
if e.get().is_u64() {
|
||||
actor_id = e.remove().as_u64();
|
||||
}
|
||||
}
|
||||
}
|
||||
AnyNotification {
|
||||
kind: Cow::Borrowed(kind),
|
||||
|
@ -69,7 +71,7 @@ impl Notification {
|
|||
serde_json::from_value(value).ok()
|
||||
}
|
||||
|
||||
pub fn all_kinds() -> &'static [&'static str] {
|
||||
pub fn all_variant_names() -> &'static [&'static str] {
|
||||
Self::VARIANTS
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,6 +155,7 @@ messages!(
|
|||
(CreateRoomResponse, Foreground),
|
||||
(DeclineCall, Foreground),
|
||||
(DeleteChannel, Foreground),
|
||||
(DeleteNotification, Foreground),
|
||||
(DeleteProjectEntry, Foreground),
|
||||
(Error, Foreground),
|
||||
(ExpandProjectEntry, Foreground),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue