diff options
-rw-r--r-- | client/components/boards/boardsList.js | 4 | ||||
-rw-r--r-- | models/boards.js | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/client/components/boards/boardsList.js b/client/components/boards/boardsList.js index cc586b1f..b1371747 100644 --- a/client/components/boards/boardsList.js +++ b/client/components/boards/boardsList.js @@ -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'); } }); diff --git a/models/boards.js b/models/boards.js index 2346ecb6..2117ff7c 100644 --- a/models/boards.js +++ b/models/boards.js @@ -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({ |