Browse Source

Merge pull request #3010 from jtbairdsr/master

fix error in notifications cleanup cron
Lauri Ojansivu 5 years ago
parent
commit
dc643f3d43
1 changed files with 3 additions and 2 deletions
  1. 3 2
      models/users.js

+ 3 - 2
models/users.js

@@ -815,7 +815,7 @@ if (Meteor.isServer) {
       user.addInvite(boardId);
       user.addInvite(boardId);
 
 
       //Check if there is a subtasks board
       //Check if there is a subtasks board
-      if (board.subtasksDefaultBoardId){
+      if (board.subtasksDefaultBoardId) {
         const subBoard = Boards.findOne(board.subtasksDefaultBoardId);
         const subBoard = Boards.findOne(board.subtasksDefaultBoardId);
         //If there is, also add user to that board
         //If there is, also add user to that board
         if (subBoard) {
         if (subBoard) {
@@ -823,7 +823,7 @@ if (Meteor.isServer) {
           user.addInvite(subBoard._id);
           user.addInvite(subBoard._id);
         }
         }
       }
       }
-      
+
       try {
       try {
         const params = {
         const params = {
           user: user.username,
           user: user.username,
@@ -952,6 +952,7 @@ const addCronJob = _.debounce(
       schedule: parser => parser.text('every 1 days'),
       schedule: parser => parser.text('every 1 days'),
       job: () => {
       job: () => {
         for (const user of Users.find()) {
         for (const user of Users.find()) {
+          if (!user.profile || !user.profile.notifications) continue;
           for (const notification of user.profile.notifications) {
           for (const notification of user.profile.notifications) {
             if (notification.read) {
             if (notification.read) {
               const removeDate = new Date(notification.read);
               const removeDate = new Date(notification.read);