Skip to content

Commit

Permalink
1 - messages: fix error with insertMany
Browse files Browse the repository at this point in the history
  • Loading branch information
Donorhan committed Aug 14, 2023
1 parent f076383 commit c3a98d8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/modules/messages/server/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ const notifyUsers = message => {
userIds = Meteor.users.find({ _id: { $ne: createdBy }, 'status.online': true, 'profile.levelId': channel }, { fields: { 'profile._id': 1 } }).fetch().map(item => item._id);
} else userIds = channel.split(';').filter(userId => userId !== createdBy);

const notifications = userIds.map(userId => ({
_id: Notifications.id(),
channelId: channel,
userId,
createdAt: new Date(),
createdBy,
}));
Notifications.rawCollection().insertMany(notifications);
if (userIds.length) {
const notifications = userIds.map(userId => ({
_id: Notifications.id(),
channelId: channel,
userId,
createdAt: new Date(),
createdBy,
}));
Promise.await(Notifications.rawCollection().insertMany(notifications));
}

log('notifyUsers: done', { userIds });
};
Expand Down

0 comments on commit c3a98d8

Please sign in to comment.