Merge pull request #11909 from pedrobmarin/update-users-persistent-data
Update users persistent data
This commit is contained in:
commit
9b4337454c
@ -21,6 +21,6 @@ export default function setloggedOutStatus(userId, meetingId, status = true) {
|
||||
try {
|
||||
UsersPersistentData.update(selector, modifier);
|
||||
} catch (err) {
|
||||
Logger.error(`Adding note to the collection: ${err}`);
|
||||
Logger.error(`Setting users persistent data's logged out status to the collection: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
import { check } from 'meteor/check';
|
||||
import UsersPersistentData from '/imports/api/users-persistent-data';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function updateRole(userId, meetingId, role) {
|
||||
check(userId, String);
|
||||
check(meetingId, String);
|
||||
check(role, String);
|
||||
|
||||
const selector = {
|
||||
userId,
|
||||
meetingId,
|
||||
};
|
||||
|
||||
const modifier = {
|
||||
$set: {
|
||||
role,
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
UsersPersistentData.update(selector, modifier);
|
||||
} catch (err) {
|
||||
Logger.error(`Updating users persistent data's role to the collection: ${err}`);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import updateRole from '/imports/api/users-persistent-data/server/modifiers/updateRole';
|
||||
import Users from '/imports/api/users';
|
||||
|
||||
export default function changeRole(role, userId, meetingId, changedBy) {
|
||||
@ -17,6 +18,7 @@ export default function changeRole(role, userId, meetingId, changedBy) {
|
||||
const numberAffected = Users.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
updateRole(userId, meetingId, role);
|
||||
Logger.info(`Changed user role=${role} id=${userId} meeting=${meetingId}`
|
||||
+ `${changedBy ? ` changedBy=${changedBy}` : ''}`);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class Subscriptions extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
let usersPersistentDataHandler = null;
|
||||
|
||||
export default withTracker(() => {
|
||||
const { credentials } = Auth;
|
||||
@ -107,7 +106,10 @@ export default withTracker(() => {
|
||||
const chatIds = chats.map(chat => chat.chatId);
|
||||
groupChatMessageHandler = Meteor.subscribe('group-chat-msg', chatIds, subscriptionErrorHandler);
|
||||
}
|
||||
if (ready && !usersPersistentDataHandler) {
|
||||
|
||||
// TODO: Refactor all the late subscribers
|
||||
let usersPersistentDataHandler = {};
|
||||
if (ready) {
|
||||
usersPersistentDataHandler = Meteor.subscribe('users-persistent-data');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user