1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 15:29:21 +00:00

Can delete group membership notifications

This commit is contained in:
Pierre HUBERT 2021-01-24 17:39:16 +01:00
parent bb06760437
commit de9304a604

View File

@ -39,7 +39,8 @@ pub fn create_friends_notification(from_user: &UserID, dest_user: &UserID, actio
/// Create & push a group membership notification
pub fn create_group_membership_notification(user_id: &UserID, moderator_id: Option<&UserID>, group_id: &GroupID, kind: NotifEventType) -> ResultBoxError {
// TODO : Delete related group membership notifications
// Delete related group membership notifications
delete_all_related_to_group_membership_notifications(user_id, group_id)?;
let mut n = PartialNotification::new()
.set_on_elem_id(group_id.id())
@ -267,6 +268,23 @@ pub fn delete_all_related_with_group(group_id: &GroupID) -> ResultBoxError {
)
}
/// Delete all the notifications related to a group membership
pub fn delete_all_related_to_group_membership_notifications(user_id: &UserID, group_id: &GroupID) -> ResultBoxError {
let mut n = PartialNotification::new()
.set_on_elem_type(NotifElemType::GROUP_MEMBERSHIP)
.set_on_elem_id(group_id.id());
n.dest_user_id = Some(user_id.clone());
n.from_user_id = None;
delete(&n)?;
n.dest_user_id = None;
n.from_user_id = Some(user_id.clone());
delete(&n)?;
Ok(())
}
/// Check out whether a similar notification exists for given specifications
pub fn similar_exists(n: &PartialNotification) -> ResultBoxError<bool> {
database::QueryInfo::new(NOTIFICATIONS_TABLE)