From 04b80782dc213c33287d206d9b47af4308133727 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 2 Aug 2018 09:23:38 +0200 Subject: [PATCH] Support group membership notifications --- assets/js/components/notifications/ui.js | 29 ++++++++++++++++++++- assets/js/components/notifications/utils.js | 3 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/assets/js/components/notifications/ui.js b/assets/js/components/notifications/ui.js index 453140b1..179386e6 100644 --- a/assets/js/components/notifications/ui.js +++ b/assets/js/components/notifications/ui.js @@ -37,6 +37,20 @@ ComunicWeb.components.notifications.ui = { message += "accepted your friendship request."; if(data.type == "rejected_friend_request") message += "rejected your friendship request."; + + //About group membership + if(data.type == "sent_group_membership_invitation") + message += "invited you to join the group"; + if(data.type == "accepted_group_membership_invitation") + message += "accepted his invitation to join the group"; + if(data.type == "rejected_group_membership_invitation") + message += "rejected his invitation to join the group"; + if(data.type == "sent_group_membership_request") + message += "sent a request to join the group"; + if(data.type == "accepted_group_membership_request") + message += "accepted your request to join the group"; + if(data.type == "rejected_group_membership_request") + message += "rejected your request to join the group"; //Generic element creation if(data.type == "elem_created"){ @@ -65,7 +79,9 @@ ComunicWeb.components.notifications.ui = { message += "on the group "+groups[data.from_container_id].name+"."; } - + //Group membership + if(data.on_elem_type == "group_membership") + message += groups[data.on_elem_id].name; //Create notification action var action = function(){ @@ -90,6 +106,17 @@ ComunicWeb.components.notifications.ui = { } + //For the group membership + if(data.on_elem_type == "group_membership"){ + + //Open appropriate page + if(data.type == "sent_group_membership_request") + openPage("groups/"+data.on_elem_id+"/members"); + else + openGroupPage(groups[data.on_elem_id]); + + } + }; //Create the notification object diff --git a/assets/js/components/notifications/utils.js b/assets/js/components/notifications/utils.js index a0bc88ff..1ef0f887 100644 --- a/assets/js/components/notifications/utils.js +++ b/assets/js/components/notifications/utils.js @@ -44,6 +44,9 @@ ComunicWeb.components.notifications.utils = { if(!groups.includes(notif.from_container_id) && notif.from_container_type == "group_page") groups.push(notif.from_container_id); + + if(!groups.includes(notif.on_elem_id) && notif.on_elem_type == "group_membership") + groups.push(notif.on_elem_id); });