Skip to content

Commit

Permalink
fix: Add missing awaits to .count() calls (#29323)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored May 23, 2023
1 parent 1687bfb commit f8cd53b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-rules-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Add missing awaits to .count() calls
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class PendingAvatarImporter extends Base {
await super.updateProgress(ProgressStep.PREPARING_STARTED);

const users = await Users.findAllUsersWithPendingAvatar();
const fileCount = users.count();
const fileCount = await users.count();

if (fileCount === 0) {
await super.updateProgress(ProgressStep.DONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Meteor.startup(() => {
return;
}

const subs = Subscriptions.find({ t: 'l', ls: { $exists: 0 }, open: true }).count();
const subs = await Subscriptions.find({ t: 'l', ls: { $exists: 0 }, open: true }).count();
if (subs === 0) {
audio && audio.pause();
return;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const dispatchInquiryQueued = async (inquiry, agent) => {
return;
}

logger.debug(`Notifying ${onlineAgents.count()} agents of new inquiry`);
logger.debug(`Notifying ${await onlineAgents.count()} agents of new inquiry`);
const notificationUserName = v && (v.name || v.username);

for await (let agent of onlineAgents) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const Livechat = {
if (settings.get('Livechat_assign_new_conversation_to_bot')) {
Livechat.logger.debug(`Fetching online bot agents for department ${department}`);
const botAgents = await Livechat.getBotAgents(department);
const onlineBots = botAgents.count();
const onlineBots = await botAgents.count();
Livechat.logger.debug(`Found ${onlineBots} online`);
if (onlineBots > 0) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/slashcommands-inviteall/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ function inviteAll<T extends string>(type: T): SlashCommand<T>['callback'] {
});

try {
const APIsettings = settings.get('API_User_Limit');
const APIsettings = settings.get<number>('API_User_Limit');
if (!APIsettings) {
return;
}
if (cursor.count() > APIsettings) {
if ((await cursor.count()) > APIsettings) {
throw new Meteor.Error('error-user-limit-exceeded', 'User Limit Exceeded', {
method: 'addAllToRoom',
});
Expand Down

0 comments on commit f8cd53b

Please sign in to comment.