Refactor: Migrate presentation upload token for the Meteor 3.0 api
This commit is contained in:
parent
029929e7d8
commit
f7b8b116e7
@ -2,7 +2,7 @@ import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
||||
|
||||
export default function handlePresentationUploadTokenFail({ body, header }, meetingId) {
|
||||
export default async function handlePresentationUploadTokenFail({ body, header }, meetingId) {
|
||||
check(body, Object);
|
||||
|
||||
const { userId } = header;
|
||||
@ -20,7 +20,8 @@ export default function handlePresentationUploadTokenFail({ body, header }, meet
|
||||
};
|
||||
|
||||
try {
|
||||
const { numberAffected } = PresentationUploadToken.upsert(selector, { failed: true, authzToken: null });
|
||||
const { numberAffected } = await PresentationUploadToken
|
||||
.upsertAsync(selector, { failed: true, authzToken: null });
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Removing presentationToken filename=${filename} podId=${podId} meeting=${meetingId}`);
|
||||
|
@ -2,7 +2,7 @@ import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
||||
|
||||
export default function handlePresentationUploadTokenPass({ body, header }, meetingId) {
|
||||
export default async function handlePresentationUploadTokenPass({ body, header }, meetingId) {
|
||||
check(body, Object);
|
||||
|
||||
const { userId } = header;
|
||||
@ -34,7 +34,7 @@ export default function handlePresentationUploadTokenPass({ body, header }, meet
|
||||
};
|
||||
|
||||
try {
|
||||
const { insertedId } = PresentationUploadToken.upsert(selector, modifier);
|
||||
const { insertedId } = await PresentationUploadToken.upsertAsync(selector, modifier);
|
||||
|
||||
if (insertedId) {
|
||||
Logger.info(`Inserting presentationToken filename=${filename} podId=${podId} meeting=${meetingId}`);
|
||||
|
@ -3,7 +3,11 @@ import { check } from 'meteor/check';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function requestPresentationUploadToken(podId, filename, temporaryPresentationId) {
|
||||
export default async function requestPresentationUploadToken(
|
||||
podId,
|
||||
filename,
|
||||
temporaryPresentationId,
|
||||
) {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'PresentationUploadTokenReqMsg';
|
||||
@ -20,7 +24,7 @@ export default function requestPresentationUploadToken(podId, filename, temporar
|
||||
const payload = {
|
||||
podId,
|
||||
filename,
|
||||
temporaryPresentationId
|
||||
temporaryPresentationId,
|
||||
};
|
||||
|
||||
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
|
@ -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 setUsedToken(authzToken) {
|
||||
export default async function setUsedToken(authzToken) {
|
||||
try {
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
|
||||
@ -17,7 +17,7 @@ export default function setUsedToken(authzToken) {
|
||||
},
|
||||
};
|
||||
|
||||
const numberAffected = PresentationUploadToken.update({
|
||||
const numberAffected = await PresentationUploadToken.updateAsync({
|
||||
meetingId,
|
||||
userId: requesterUserId,
|
||||
authzToken,
|
||||
|
@ -1,10 +1,13 @@
|
||||
import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function clearPresentationUploadToken(meetingId, podId) {
|
||||
export default async function clearPresentationUploadToken(
|
||||
meetingId,
|
||||
podId,
|
||||
) {
|
||||
if (meetingId && podId) {
|
||||
try {
|
||||
const numberAffected = PresentationUploadToken.remove({ meetingId, podId });
|
||||
const numberAffected = await PresentationUploadToken.removeAsync({ meetingId, podId });
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Cleared Presentations Upload Token (${meetingId}, ${podId})`);
|
||||
@ -18,7 +21,7 @@ export default function clearPresentationUploadToken(meetingId, podId) {
|
||||
|
||||
if (meetingId) {
|
||||
try {
|
||||
const numberAffected = PresentationUploadToken.remove({ meetingId });
|
||||
const numberAffected = await PresentationUploadToken.removeAsync({ meetingId });
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Cleared Presentations Upload Token (${meetingId})`);
|
||||
@ -29,7 +32,7 @@ export default function clearPresentationUploadToken(meetingId, podId) {
|
||||
} else {
|
||||
try {
|
||||
// clearing presentations for the whole server
|
||||
const numberAffected = PresentationUploadToken.remove({});
|
||||
const numberAffected = await PresentationUploadToken.removeAsync({});
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info('Cleared Presentations Upload Token (all)');
|
||||
|
@ -4,8 +4,9 @@ import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
|
||||
|
||||
function presentationUploadToken(podId, filename, temporaryPresentationId) {
|
||||
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
|
||||
async function presentationUploadToken(podId, filename, temporaryPresentationId) {
|
||||
const tokenValidation = await AuthTokenValidation
|
||||
.findOneAsync({ connectionId: this.connection.id });
|
||||
|
||||
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
||||
Logger.warn(`Publishing PresentationUploadToken was requested by unauth connection ${this.connection.id}`);
|
||||
|
Loading…
Reference in New Issue
Block a user