Users info back-end migrated to new async API
This commit is contained in:
parent
314395298b
commit
c701ff5c66
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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}`);
|
||||
|
@ -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}`);
|
||||
|
@ -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})`);
|
||||
|
@ -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}`);
|
||||
|
@ -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}`);
|
||||
|
Loading…
Reference in New Issue
Block a user