diff options
author | Liming Xie <liming.xie@gmail.com> | 2016-01-05 23:26:02 +0800 |
---|---|---|
committer | Liming Xie <liming.xie@gmail.com> | 2016-01-05 23:26:02 +0800 |
commit | 9bbdacc79a89667e0d6f1ed30c415e5350ad468b (patch) | |
tree | fc6d9918dcd77699295ecb5bdbaf59f9d7c2f479 /models/users.js | |
parent | 9ef8ebaf09e52d7133ebe08ab1354ef663ee948b (diff) | |
download | wekan-9bbdacc79a89667e0d6f1ed30c415e5350ad468b.tar.gz wekan-9bbdacc79a89667e0d6f1ed30c415e5350ad468b.tar.bz2 wekan-9bbdacc79a89667e0d6f1ed30c415e5350ad468b.zip |
Add notification, allow watch boards / lists / cards
Diffstat (limited to 'models/users.js')
-rw-r--r-- | models/users.js | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/models/users.js b/models/users.js index 5d9c218a..3bb7324f 100644 --- a/models/users.js +++ b/models/users.js @@ -47,6 +47,21 @@ Users.helpers({ return _.contains(invitedBoards, boardId); }, + hasTag(tag) { + const {tags = []} = this.profile; + return _.contains(tags, tag); + }, + + hasNotification(activityId) { + const {notifications = []} = this.profile; + return _.contains(notifications, activityId); + }, + + getEmailCache() { + const {emailCache = []} = this.profile; + return emailCache; + }, + getInitials() { const profile = this.profile || {}; if (profile.initials) @@ -99,6 +114,61 @@ Users.mutations({ }; }, + addTag(tag) { + return { + $addToSet: { + 'profile.tags': tag, + }, + }; + }, + + removeTag(tag) { + return { + $pull: { + 'profile.tags': tag, + }, + }; + }, + + toggleTag(tag) { + if (this.hasTag(tag)) + this.removeTag(tag); + else + this.addTag(tag); + }, + + addNotification(activityId) { + return { + $addToSet: { + 'profile.notifications': activityId, + }, + }; + }, + + removeNotification(activityId) { + return { + $pull: { + 'profile.notifications': activityId, + }, + }; + }, + + addEmailCache(text) { + return { + $addToSet: { + 'profile.emailCache': text, + }, + }; + }, + + clearEmailCache() { + return { + $set: { + 'profile.emailCache': [], + }, + }; + }, + setAvatarUrl(avatarUrl) { return { $set: { 'profile.avatarUrl': avatarUrl }}; }, @@ -167,21 +237,18 @@ if (Meteor.isServer) { user.addInvite(boardId); try { - const { _id, slug } = board; - const boardUrl = FlowRouter.url('board', { id: _id, slug }); - - const vars = { + const params = { user: user.username, inviter: inviter.username, board: board.title, - url: boardUrl, + url: board.absoluteUrl(), }; const lang = user.getLanguage(); Email.send({ to: user.emails[0].address, from: Accounts.emailTemplates.from, - subject: TAPi18n.__('email-invite-subject', vars, lang), - text: TAPi18n.__('email-invite-text', vars, lang), + subject: TAPi18n.__('email-invite-subject', params, lang), + text: TAPi18n.__('email-invite-text', params, lang), }); } catch (e) { throw new Meteor.Error('email-fail', e.message); |