From 721ea88bd05e880c4bb720b03b81fe6ed2330060 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Wed, 3 Aug 2016 16:30:34 +0100 Subject: [PATCH] If email is already invited, resend the invite --- .../Collaborators/CollaboratorsInviteController.coffee | 2 +- .../share/controllers/ShareProjectModalController.coffee | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee index 1977a4e01d..69b85a0a4d 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee @@ -56,7 +56,7 @@ module.exports = CollaboratorsInviteController = logger.log {projectId, inviteId}, "resending invite" CollaboratorsInviteHandler.resendInvite projectId, inviteId, (err) -> if err? - logger.err {projectId, inviteId}, "error revoking invite" + logger.err {projectId, inviteId}, "error resending invite" return next(err) res.sendStatus(201) diff --git a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee index a368bbb4f2..0f93d925d4 100644 --- a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee +++ b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee @@ -43,6 +43,9 @@ define [ getCurrentMemberEmails = () -> $scope.project.members.map (u) -> u.email + getCurrentInviteEmails = () -> + $scope.project.invites.map (u) -> u.email + $scope.filterAutocompleteUsers = ($query) -> currentMemberEmails = getCurrentMemberEmails() return $scope.autocompleteContacts.filter (contact) -> @@ -63,6 +66,7 @@ define [ $scope.state.inflight = true currentMemberEmails = getCurrentMemberEmails() + currentInviteEmails = getCurrentInviteEmails() do addNextMember = () -> if members.length == 0 or !$scope.canAddCollaborators $scope.state.inflight = false @@ -75,7 +79,9 @@ define [ return addNextMember() # NOTE: groups aren't really a thing in ShareLaTeX, partially inherited from DJ - if member.type == "user" + if member.display in currentInviteEmails and inviteId = _.find($scope.project.invites, (invite) -> invite.email == member.display)?._id + request = projectInvites.resendInvite(inviteId) + else if member.type == "user" request = projectInvites.sendInvite(member.email, $scope.inputs.privileges) else if member.type == "group" request = projectMembers.addGroup(member.id, $scope.inputs.privileges)