summaryrefslogtreecommitdiffstats
path: root/models/users.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/users.js')
-rw-r--r--models/users.js81
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);