mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-29 08:46:27 +00:00
Send notifications for users who asked for it
This commit is contained in:
parent
42c7425aae
commit
2e5d8ed305
@ -9,7 +9,7 @@ use crate::data::error::Res;
|
|||||||
use crate::data::push_notification::PushNotification;
|
use crate::data::push_notification::PushNotification;
|
||||||
use crate::data::user::UserID;
|
use crate::data::user::UserID;
|
||||||
use crate::data::user_token::{PushNotificationToken, UserAccessToken};
|
use crate::data::user_token::{PushNotificationToken, UserAccessToken};
|
||||||
use crate::helpers::{account_helper, conversations_helper, independent_push_notifications_service_helper, user_helper, firebase_notifications_helper};
|
use crate::helpers::{account_helper, conversations_helper, firebase_notifications_helper, independent_push_notifications_service_helper, user_helper};
|
||||||
use crate::helpers::events_helper::Event;
|
use crate::helpers::events_helper::Event;
|
||||||
|
|
||||||
/// Un-register for previous push notifications service
|
/// Un-register for previous push notifications service
|
||||||
@ -136,13 +136,21 @@ pub fn create_conversation_notification(msg: &ConversationMessage) -> Res {
|
|||||||
timeout: None,
|
timeout: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let list = conversations_helper::get_list_members(msg.conv_id)?
|
let list: Vec<UserID> = conversations_helper::get_list_members(msg.conv_id)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|m| m.following && m.user_id != user_id)
|
.filter(|m| m.following && m.user_id != user_id)
|
||||||
.map(|m| m.user_id)
|
.map(|m| m.user_id)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
push_notification_to_users(¬if, list)
|
// Select only users who allowed push notifications
|
||||||
|
let mut dest_list = vec![];
|
||||||
|
for el in list {
|
||||||
|
if user_helper::find_user_by_id(&el)?.allow_notif_conv {
|
||||||
|
dest_list.push(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
push_notification_to_users(¬if, dest_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dismiss a conversation notification
|
/// Dismiss a conversation notification
|
||||||
|
Loading…
Reference in New Issue
Block a user