From c701ff5c66b65968f69c85cc494dcaa7a6f202ce Mon Sep 17 00:00:00 2001 From: imdt Date: Thu, 9 Mar 2023 10:30:34 -0300 Subject: [PATCH] Users info back-end migrated to new async API --- bigbluebutton-html5/imports/api/users-infos/index.js | 2 +- .../api/users-infos/server/handlers/userInformation.js | 5 +++-- .../api/users-infos/server/methods/removeUserInformation.js | 4 ++-- .../imports/api/users-infos/server/modifiers/addUserInfo.js | 4 ++-- .../api/users-infos/server/modifiers/clearUserInfo.js | 4 ++-- .../server/modifiers/clearUserInfoForRequester.js | 4 ++-- .../imports/api/users-infos/server/publishers.js | 5 +++-- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/bigbluebutton-html5/imports/api/users-infos/index.js b/bigbluebutton-html5/imports/api/users-infos/index.js index 414714f95c..ee64f75c96 100644 --- a/bigbluebutton-html5/imports/api/users-infos/index.js +++ b/bigbluebutton-html5/imports/api/users-infos/index.js @@ -7,7 +7,7 @@ const collectionOptions = Meteor.isClient ? { const UserInfos = new Mongo.Collection('users-infos', collectionOptions); if (Meteor.isServer) { - UserInfos._ensureIndex({ meetingId: 1, userId: 1 }); + UserInfos.createIndexAsync({ meetingId: 1, userId: 1 }); } export default UserInfos; diff --git a/bigbluebutton-html5/imports/api/users-infos/server/handlers/userInformation.js b/bigbluebutton-html5/imports/api/users-infos/server/handlers/userInformation.js index 795aed2854..6f3262cae3 100644 --- a/bigbluebutton-html5/imports/api/users-infos/server/handlers/userInformation.js +++ b/bigbluebutton-html5/imports/api/users-infos/server/handlers/userInformation.js @@ -1,7 +1,7 @@ import { check } from 'meteor/check'; import addUserInfo from '../modifiers/addUserInfo'; -export default function handleUserInformation({ header, body }) { +export default async function handleUserInformation({ header, body }) { check(body, Object); check(header, Object); @@ -12,5 +12,6 @@ export default function handleUserInformation({ header, body }) { check(userId, String); check(meetingId, String); - return addUserInfo(userInfo, userId, meetingId); + const result = await addUserInfo(userInfo, userId, meetingId); + return result; } diff --git a/bigbluebutton-html5/imports/api/users-infos/server/methods/removeUserInformation.js b/bigbluebutton-html5/imports/api/users-infos/server/methods/removeUserInformation.js index 7766f642c7..66e762060d 100644 --- a/bigbluebutton-html5/imports/api/users-infos/server/methods/removeUserInformation.js +++ b/bigbluebutton-html5/imports/api/users-infos/server/methods/removeUserInformation.js @@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger'; import { extractCredentials } from '/imports/api/common/server/helpers'; import { check } from 'meteor/check'; -export default function removeUserInformation() { +export default async function removeUserInformation() { try { const { meetingId, requesterUserId } = extractCredentials(this.userId); @@ -15,7 +15,7 @@ export default function removeUserInformation() { requesterUserId, }; - const numberAffected = UserInfos.remove(selector); + const numberAffected = await UserInfos.removeAsync(selector); if (numberAffected) { Logger.info(`Removed user information: requester id=${requesterUserId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users-infos/server/modifiers/addUserInfo.js b/bigbluebutton-html5/imports/api/users-infos/server/modifiers/addUserInfo.js index ca1491cf25..882f0eface 100644 --- a/bigbluebutton-html5/imports/api/users-infos/server/modifiers/addUserInfo.js +++ b/bigbluebutton-html5/imports/api/users-infos/server/modifiers/addUserInfo.js @@ -1,7 +1,7 @@ import UserInfos from '/imports/api/users-infos'; import Logger from '/imports/startup/server/logger'; -export default function addUserInfo(userInfo, requesterUserId, meetingId) { +export default async function addUserInfo(userInfo, requesterUserId, meetingId) { const info = { meetingId, requesterUserId, @@ -9,7 +9,7 @@ export default function addUserInfo(userInfo, requesterUserId, meetingId) { }; try { - const numberAffected = UserInfos.insert(info); + const numberAffected = await UserInfos.insertAsync(info); if (numberAffected) { Logger.info(`Added user information: requester id=${requesterUserId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfo.js b/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfo.js index 1ad70fbf77..ca76f67502 100644 --- a/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfo.js +++ b/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfo.js @@ -1,9 +1,9 @@ import UserInfos from '/imports/api/users-infos'; import Logger from '/imports/startup/server/logger'; -export default function clearUsersInfo(meetingId) { +export default async function clearUsersInfo(meetingId) { try { - const numberAffected = UserInfos.remove({ meetingId }); + const numberAffected = await UserInfos.removeAsync({ meetingId }); if (numberAffected) { Logger.info(`Cleared User Infos (${meetingId})`); diff --git a/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfoForRequester.js b/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfoForRequester.js index ee60500541..8766fe4166 100644 --- a/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfoForRequester.js +++ b/bigbluebutton-html5/imports/api/users-infos/server/modifiers/clearUserInfoForRequester.js @@ -1,9 +1,9 @@ import UserInfos from '/imports/api/users-infos'; import Logger from '/imports/startup/server/logger'; -export default function clearUsersInfoForRequester(meetingId, requesterUserId) { +export default async function clearUsersInfoForRequester(meetingId, requesterUserId) { try { - const numberAffected = UserInfos.remove({ meetingId }); + const numberAffected = await UserInfos.removeAsync({ meetingId }); if (numberAffected) { Logger.info(`Cleared User Infos requested by user=${requesterUserId}`); diff --git a/bigbluebutton-html5/imports/api/users-infos/server/publishers.js b/bigbluebutton-html5/imports/api/users-infos/server/publishers.js index 8ea39e4d00..0bdc333c40 100644 --- a/bigbluebutton-html5/imports/api/users-infos/server/publishers.js +++ b/bigbluebutton-html5/imports/api/users-infos/server/publishers.js @@ -3,8 +3,9 @@ import UserInfos from '/imports/api/users-infos'; import Logger from '/imports/startup/server/logger'; import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation'; -function userInfos() { - const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id }); +async function userInfos() { + const tokenValidation = await AuthTokenValidation + .findOneAsync({ connectionId: this.connection.id }); if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) { Logger.warn(`Publishing UserInfos was requested by unauth connection ${this.connection.id}`);