From 3ceb2ae13dc1990beda99695ebc10bd6c2f974fd Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 24 Jan 2021 18:37:07 +0100 Subject: [PATCH] Create notification when sending a group membership request --- src/controllers/groups_controller.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/controllers/groups_controller.rs b/src/controllers/groups_controller.rs index 7e988aa..45a131d 100644 --- a/src/controllers/groups_controller.rs +++ b/src/controllers/groups_controller.rs @@ -241,13 +241,18 @@ pub fn send_request(r: &mut HttpRequestHandler) -> RequestResult { groups_helper::insert_member(&GroupMember { id: 0, user_id: r.user_id()?, - group_id, + group_id: group_id.clone(), time_create: time(), level, following: true, })?; - // TODO : Send a notification, if required + // Send a notification, if required + if matches!(group.registration_level, GroupRegistrationLevel::MODERATED_REGISTRATION) { + notifications_helper::create_group_membership_notification(r.user_id_ref()?, None, + &group_id, NotifEventType::SENT_GROUP_MEMBERSHIP_REQUEST)?; + } + r.success("The membership has been successfully saved!") }