From 1a2a381ae3172f0383b6244b57938f0d48d648ce Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 14 Aug 2019 15:50:03 -0400 Subject: [PATCH] feat: notification on membership acceptance, closes #7835 --- public/language/en-GB/groups.json | 1 + src/groups/invite.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/public/language/en-GB/groups.json b/public/language/en-GB/groups.json index 00019c35d6..9a37255a6b 100644 --- a/public/language/en-GB/groups.json +++ b/public/language/en-GB/groups.json @@ -55,6 +55,7 @@ "event.deleted": "The group \"%1\" has been deleted", "membership.accept-invitation": "Accept Invitation", + "membership.accept.notification_title": "You are now a member of %1", "membership.invitation-pending": "Invitation Pending", "membership.join-group": "Join Group", "membership.leave-group": "Leave Group", diff --git a/src/groups/invite.js b/src/groups/invite.js index 364cf0f6b8..295972b6be 100644 --- a/src/groups/invite.js +++ b/src/groups/invite.js @@ -28,6 +28,14 @@ module.exports = function (Groups) { Groups.acceptMembership = async function (groupName, uid) { await db.setsRemove(['group:' + groupName + ':pending', 'group:' + groupName + ':invited'], uid); await Groups.join(groupName, uid); + + const notification = await notifications.create({ + type: 'group-invite', + bodyShort: '[[groups:membership.accept.notification_title, ' + groupName + ']]', + nid: 'group:' + groupName + ':uid:' + uid + ':invite-accepted', + path: '/groups/' + utils.slugify(groupName), + }); + await notifications.push(notification, [uid]); }; Groups.rejectMembership = async function (groupNames, uid) {