WIP remove callback from update methods
This commit is contained in:
parent
e4a5e88986
commit
ccda3b3a34
@ -27,15 +27,13 @@ export default function joinedUsersChanged({ body }) {
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const numberAffected = Breakouts.update(selector, modifier);
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`updating joined users in breakout: ${err}`);
|
||||
if (numberAffected) {
|
||||
Logger.info(`Updated joined users in breakout id=${breakoutId}`);
|
||||
}
|
||||
|
||||
return Logger.info('Updated joined users '
|
||||
+ `in breakout id=${breakoutId}`);
|
||||
};
|
||||
Breakouts.find(selector);
|
||||
Breakouts.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`updating joined users in breakout: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -24,14 +24,13 @@ export default function handleUpdateTimeRemaining({ body }, meetingId) {
|
||||
multi: true,
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Updating breakouts: ${err}`);
|
||||
try {
|
||||
const numberAffected = Breakouts.update(selector, modifier, options);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Updated breakout time remaining for breakouts where parentMeetingId=${meetingId}`);
|
||||
}
|
||||
|
||||
return Logger.info('Updated breakout time remaining for breakouts ' +
|
||||
`where parentMeetingId=${meetingId}`);
|
||||
};
|
||||
|
||||
return Breakouts.update(selector, modifier, options, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Updating breakouts: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,14 @@ export default function updateOwnerId(meetingId, userId, padId) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error('Captions: error while updating pad', { err });
|
||||
}
|
||||
updateOwner(meetingId, userId, padId);
|
||||
return Logger.verbose('Captions: updated caption', { padId, ownerId: userId });
|
||||
};
|
||||
try {
|
||||
const numberAffected = Captions.update(selector, modifier, { multi: true });
|
||||
|
||||
return Captions.update(selector, modifier, { multi: true }, cb);
|
||||
if (numberAffected) {
|
||||
updateOwner(meetingId, userId, padId);
|
||||
Logger.verbose('Captions: updated caption', { padId, ownerId: userId });
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error('Captions: error while updating pad', { err });
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,14 @@ export default function updatePad(padId, data, revs) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Updating captions pad: ${err}`);
|
||||
}
|
||||
editCaptions(padId, data, revs);
|
||||
return Logger.verbose('Captions: updated pad', { padId, revs });
|
||||
};
|
||||
try {
|
||||
const numberAffected = Captions.update(selector, modifier, { multi: true });
|
||||
|
||||
return Captions.update(selector, modifier, { multi: true }, cb);
|
||||
if (numberAffected) {
|
||||
editCaptions(padId, data, revs);
|
||||
Logger.verbose('Captions: updated pad', { padId, revs });
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Updating captions pad: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ export default function updateReadOnlyPadId(padId, readOnlyPadId) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error('Captions: error when adding readOnlyPadId', { err });
|
||||
try {
|
||||
const numberAffected = Captions.update(selector, modifier, { multi: true });
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.verbose('Captions: added readOnlyPadId', { padId, readOnlyPadId });
|
||||
}
|
||||
|
||||
return Logger.verbose('Captions: added readOnlyPadId', { padId, readOnlyPadId });
|
||||
};
|
||||
|
||||
return Captions.update(selector, modifier, { multi: true }, cb);
|
||||
} catch (err) {
|
||||
Logger.error('Captions: error when adding readOnlyPadId', { err });
|
||||
}
|
||||
}
|
||||
|
@ -14,28 +14,27 @@ export default function handleGuestsWaitingForApproval({ body }, meetingId) {
|
||||
check(guests, Array);
|
||||
check(meetingId, String);
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
return Logger.error(`Adding guest user to collection: ${err}`);
|
||||
return guests.map((guest) => {
|
||||
try {
|
||||
const { insertedId, numberAffected } = GuestUsers.upsert({
|
||||
meetingId,
|
||||
intId: guest.intId,
|
||||
}, {
|
||||
approved: false,
|
||||
denied: false,
|
||||
...guest,
|
||||
meetingId,
|
||||
loginTime: new Date().getTime(),
|
||||
color: COLOR_LIST[stringHash(guest.intId) % COLOR_LIST.length],
|
||||
});
|
||||
|
||||
if (insertedId) {
|
||||
Logger.info(`Added guest user meeting=${meetingId}`);
|
||||
} else if (numberAffected) {
|
||||
Logger.info(`Upserted guest user meeting=${meetingId}`);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Adding guest user to collection: ${err}`);
|
||||
}
|
||||
|
||||
const { insertedId } = numChanged;
|
||||
if (insertedId) {
|
||||
return Logger.info(`Added guest user meeting=${meetingId}`);
|
||||
}
|
||||
|
||||
return Logger.info(`Upserted guest user meeting=${meetingId}`);
|
||||
};
|
||||
|
||||
return guests.map(guest => GuestUsers.upsert({
|
||||
meetingId,
|
||||
intId: guest.intId,
|
||||
}, {
|
||||
approved: false,
|
||||
denied: false,
|
||||
...guest,
|
||||
meetingId,
|
||||
loginTime: new Date().getTime(),
|
||||
color: COLOR_LIST[stringHash(guest.intId) % COLOR_LIST.length],
|
||||
}, cb));
|
||||
});
|
||||
}
|
||||
|
@ -21,13 +21,14 @@ export default function setGuestStatus(meetingId, intId, status, approvedBy = nu
|
||||
approvedBy,
|
||||
},
|
||||
};
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Updating status=${status} user=${intId}: ${err}`);
|
||||
|
||||
try {
|
||||
const numberAffected = GuestUsers.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Updated status=${status} user=${intId} meeting=${meetingId}`);
|
||||
}
|
||||
|
||||
return Logger.info(`Updated status=${status} user=${intId} meeting=${meetingId}`);
|
||||
};
|
||||
|
||||
return GuestUsers.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Updating status=${status} user=${intId}: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -150,15 +150,23 @@ export default function addMeeting(meeting) {
|
||||
})),
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
Logger.error(`Adding meeting to collection: ${err}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { insertedId, numberAffected } = RecordMeetings.upsert(selector, { meetingId, ...recordProp });
|
||||
|
||||
const {
|
||||
insertedId,
|
||||
} = numChanged;
|
||||
if (insertedId) {
|
||||
Logger.info(`Added record prop id=${meetingId}`);
|
||||
} else if (numberAffected) {
|
||||
Logger.info(`Upserted record prop id=${meetingId}`);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Adding record prop to collection: ${err}`);
|
||||
}
|
||||
|
||||
try {
|
||||
const { insertedId, numberAffected } = Meetings.upsert(selector, modifier);
|
||||
|
||||
addAnnotationsStreamer(meetingId);
|
||||
addCursorStreamer(meetingId);
|
||||
|
||||
if (insertedId) {
|
||||
Logger.info(`Added meeting id=${meetingId}`);
|
||||
@ -167,39 +175,10 @@ export default function addMeeting(meeting) {
|
||||
createNote(meetingId);
|
||||
createCaptions(meetingId);
|
||||
BannedUsers.init(meetingId);
|
||||
}
|
||||
|
||||
if (numChanged) {
|
||||
} else if (numberAffected) {
|
||||
Logger.info(`Upserted meeting id=${meetingId}`);
|
||||
}
|
||||
};
|
||||
|
||||
const cbRecord = (err, numChanged) => {
|
||||
if (err) {
|
||||
Logger.error(`Adding record prop to collection: ${err}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
insertedId,
|
||||
} = numChanged;
|
||||
|
||||
if (insertedId) {
|
||||
Logger.info(`Added record prop id=${meetingId}`);
|
||||
}
|
||||
|
||||
if (numChanged) {
|
||||
Logger.info(`Upserted record prop id=${meetingId}`);
|
||||
}
|
||||
};
|
||||
|
||||
RecordMeetings.upsert(selector, {
|
||||
meetingId,
|
||||
...recordProp,
|
||||
}, cbRecord);
|
||||
|
||||
addAnnotationsStreamer(meetingId);
|
||||
addCursorStreamer(meetingId);
|
||||
|
||||
return Meetings.upsert(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Adding meeting to collection: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ export default function updateNote(noteId, revs) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error('Notes: error when updating note pad', { err });
|
||||
try {
|
||||
const numberAffected = Note.update(selector, modifier, { multi: true });
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.verbose('Notes: update note pad', { pad: noteId, revs });
|
||||
}
|
||||
|
||||
return Logger.verbose('Notes: update note pad', { pad: noteId, revs });
|
||||
};
|
||||
|
||||
return Note.update(selector, modifier, { multi: true }, cb);
|
||||
} catch (err) {
|
||||
Logger.error('Notes: error when updating note pad', { err });
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,9 @@ export default function ping() {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Error updating lastPing for ${requesterUserId}: ${err}`);
|
||||
}
|
||||
};
|
||||
|
||||
return Users.update(selector, modifier, cb);
|
||||
try {
|
||||
Users.update(selector, modifier);
|
||||
} catch (err) {
|
||||
Logger.error(`Error updating lastPing for ${requesterUserId}: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -22,14 +22,13 @@ export default function userResponded({ body }) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Updating Poll responses: ${err}`);
|
||||
try {
|
||||
const numberAffected = Polls.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Updating Poll response (userId: ${userId}, response: ${answerId}, pollId: ${pollId})`);
|
||||
}
|
||||
|
||||
return Logger.info(`Updating Poll response (userId: ${userId},`
|
||||
+ `response: ${answerId}, pollId: ${pollId})`);
|
||||
};
|
||||
|
||||
return Polls.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Updating Poll responses: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -48,16 +48,15 @@ export default function publishVote(pollId, pollAnswerId) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Removing responded user from Polls collection: ${err}`);
|
||||
try {
|
||||
const numberAffected = Polls.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Removed responded user=${requesterUserId} from poll (meetingId: ${meetingId}, pollId: ${pollId}!)`);
|
||||
|
||||
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
}
|
||||
|
||||
Logger.info(`Removed responded user=${requesterUserId} from poll (meetingId: ${meetingId}, `
|
||||
+ `pollId: ${pollId}!)`);
|
||||
|
||||
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
};
|
||||
|
||||
Polls.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Removing responded user from Polls collection: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ export default function updateVotes(poll, meetingId) {
|
||||
$set: flat(poll, { safe: true }),
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Updating Polls collection: ${err}`);
|
||||
try {
|
||||
const numberAffected = Polls.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Updating Polls collection (meetingId: ${meetingId}, pollId: ${id}!)`);
|
||||
}
|
||||
|
||||
return Logger.info(`Updating Polls collection (meetingId: ${meetingId}, pollId: ${id}!)`);
|
||||
};
|
||||
|
||||
return Polls.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Updating Polls collection: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -10,18 +10,18 @@ export default function setUsedToken(authzToken) {
|
||||
used: true,
|
||||
},
|
||||
};
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
Logger.error(`Unable to set token as used : ${err}`);
|
||||
return;
|
||||
|
||||
try {
|
||||
const numberAffected = PresentationUploadToken.update({
|
||||
meetingId,
|
||||
userId: requesterUserId,
|
||||
authzToken,
|
||||
}, payload);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Token: ${authzToken} has been set as used in meeting=${meetingId}`);
|
||||
}
|
||||
|
||||
Logger.info(`Token: ${authzToken} has been set as used in meeting=${meetingId}`);
|
||||
};
|
||||
|
||||
return PresentationUploadToken.update({
|
||||
meetingId,
|
||||
userId: requesterUserId,
|
||||
authzToken,
|
||||
}, payload, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Unable to set token as used : ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -91,22 +91,6 @@ export default function addSlide(meetingId, podId, presentationId, slide) {
|
||||
),
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
return Logger.error(`Adding slide to collection: ${err}`);
|
||||
}
|
||||
|
||||
const { insertedId } = numChanged;
|
||||
|
||||
requestWhiteboardHistory(meetingId, slideId);
|
||||
|
||||
if (insertedId) {
|
||||
return Logger.info(`Added slide id=${slideId} pod=${podId} presentation=${presentationId}`);
|
||||
}
|
||||
|
||||
return Logger.info(`Upserted slide id=${slideId} pod=${podId} presentation=${presentationId}`);
|
||||
};
|
||||
|
||||
const imageSizeUri = (loadSlidesFromHttpAlways ? imageUri.replace(/^https/i, 'http') : imageUri);
|
||||
|
||||
return fetchImageSizes(imageSizeUri)
|
||||
@ -129,7 +113,20 @@ export default function addSlide(meetingId, podId, presentationId, slide) {
|
||||
addSlidePositions(meetingId, podId, presentationId, slideId, slidePosition);
|
||||
}
|
||||
|
||||
return Slides.upsert(selector, modifier, cb);
|
||||
try {
|
||||
const { insertedId, numberAffected } = Slides.upsert(selector, modifier);
|
||||
|
||||
requestWhiteboardHistory(meetingId, slideId);
|
||||
|
||||
if (insertedId) {
|
||||
Logger.info(`Added slide id=${slideId} pod=${podId} presentation=${presentationId}`);
|
||||
} else if (numberAffected) {
|
||||
Logger.info(`Upserted slide id=${slideId} pod=${podId} presentation=${presentationId}`);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
Logger.error(`Error on adding slide to collection: ${err}`);
|
||||
}
|
||||
})
|
||||
.catch(reason => Logger.error(`Error parsing image size. ${reason}. slide=${slideId} uri=${imageUri}`));
|
||||
}
|
||||
|
@ -7,12 +7,14 @@ export default function addUserInfo(userInfo, requesterUserId, meetingId) {
|
||||
requesterUserId,
|
||||
userInfo,
|
||||
};
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Adding user information to collection: ${err}`);
|
||||
}
|
||||
return Logger.info(`Added user information: requester id=${requesterUserId} meeting=${meetingId}`);
|
||||
};
|
||||
|
||||
return UserInfos.insert(info, cb);
|
||||
try {
|
||||
const numberAffected = UserInfos.insert(info);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Added user information: requester id=${requesterUserId} meeting=${meetingId}`);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Adding user information to collection: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -28,15 +28,14 @@ export default function removeVoiceUser(meetingId, voiceUser) {
|
||||
},
|
||||
};
|
||||
|
||||
clearSpokeTimeout(meetingId, intId);
|
||||
try {
|
||||
clearSpokeTimeout(meetingId, intId);
|
||||
const numberAffected = VoiceUsers.update(selector, modifier);
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Remove voiceUser=${intId}: ${err}`);
|
||||
if (numberAffected) {
|
||||
Logger.info(`Remove voiceUser=${intId} meeting=${meetingId}`);
|
||||
}
|
||||
|
||||
return Logger.info(`Remove voiceUser=${intId} meeting=${meetingId}`);
|
||||
};
|
||||
|
||||
return VoiceUsers.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Remove voiceUser=${intId}: ${err}`);
|
||||
}
|
||||
}
|
||||
|
@ -43,14 +43,6 @@ export default function updateVoiceUser(meetingId, voiceUser) {
|
||||
clearSpokeTimeout(meetingId, intId);
|
||||
}
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Update voiceUser=${intId}: ${err}`);
|
||||
}
|
||||
|
||||
return Logger.debug('Update voiceUser', { voiceUser: intId, meetingId });
|
||||
};
|
||||
|
||||
if (!voiceUser.talking) {
|
||||
const timeoutHandle = Meteor.setTimeout(() => {
|
||||
const user = VoiceUsers.findOne({ meetingId, intId }, {
|
||||
@ -66,7 +58,15 @@ export default function updateVoiceUser(meetingId, voiceUser) {
|
||||
if (talking || spokeDelay) return;
|
||||
modifier.$set.spoke = false;
|
||||
modifier.$set.startTime = null;
|
||||
VoiceUsers.update(selector, modifier, cb);
|
||||
try {
|
||||
const numberAffected = VoiceUsers.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.debug('Update voiceUser', { voiceUser: intId, meetingId });
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Update voiceUser=${intId}: ${err}`);
|
||||
}
|
||||
}
|
||||
}, TALKING_TIMEOUT);
|
||||
|
||||
@ -74,5 +74,13 @@ export default function updateVoiceUser(meetingId, voiceUser) {
|
||||
modifier.$set.endTime = Date.now();
|
||||
}
|
||||
|
||||
return VoiceUsers.update(selector, modifier, cb);
|
||||
try {
|
||||
const numberAffected = VoiceUsers.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.debug('Update voiceUser', { voiceUser: intId, meetingId });
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Update voiceUser=${intId}: ${err}`);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user