Merge pull request #2549 from justinr1234/fix-invite

Fix invites
This commit is contained in:
Lauri Ojansivu 2019-07-18 22:24:52 +03:00 committed by GitHub
commit 3bd0f6f911
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -82,13 +82,13 @@ BlazeComponent.extendComponent({
},
'click .js-accept-invite'() {
const boardId = this.currentData()._id;
Meteor.user().removeInvite(boardId);
Meteor.call('acceptInvite', boardId);
},
'click .js-decline-invite'() {
const boardId = this.currentData()._id;
Meteor.call('quitBoard', boardId, (err, ret) => {
if (!err && ret) {
Meteor.user().removeInvite(boardId);
Meteor.call('acceptInvite', boardId);
FlowRouter.go('home');
}
});

View file

@ -952,6 +952,19 @@ if (Meteor.isServer) {
} else throw new Meteor.Error('error-board-notAMember');
} else throw new Meteor.Error('error-board-doesNotExist');
},
acceptInvite(boardId) {
check(boardId, String);
const board = Boards.findOne(boardId);
if (!board) {
throw new Meteor.Error('error-board-doesNotExist');
}
Meteor.users.update(Meteor.userId(), {
$pull: {
'profile.invitedBoards': boardId,
},
});
},
});
Meteor.methods({