2017-05-06 04:17:38 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-06-07 20:28:41 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-05-06 04:17:38 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
|
|
|
|
2017-06-07 20:28:41 +08:00
|
|
|
// const OFFICE_DOC_CONVERSION_SUCCESS_KEY = 'OFFICE_DOC_CONVERSION_SUCCESS';
|
2017-05-06 04:17:38 +08:00
|
|
|
const OFFICE_DOC_CONVERSION_FAILED_KEY = 'OFFICE_DOC_CONVERSION_FAILED';
|
|
|
|
const OFFICE_DOC_CONVERSION_INVALID_KEY = 'OFFICE_DOC_CONVERSION_INVALID';
|
|
|
|
const SUPPORTED_DOCUMENT_KEY = 'SUPPORTED_DOCUMENT';
|
|
|
|
const UNSUPPORTED_DOCUMENT_KEY = 'UNSUPPORTED_DOCUMENT';
|
|
|
|
const PAGE_COUNT_FAILED_KEY = 'PAGE_COUNT_FAILED';
|
|
|
|
const PAGE_COUNT_EXCEEDED_KEY = 'PAGE_COUNT_EXCEEDED';
|
|
|
|
const GENERATED_SLIDE_KEY = 'GENERATED_SLIDE';
|
2017-06-07 20:28:41 +08:00
|
|
|
// const GENERATING_THUMBNAIL_KEY = 'GENERATING_THUMBNAIL';
|
|
|
|
// const GENERATED_THUMBNAIL_KEY = 'GENERATED_THUMBNAIL';
|
|
|
|
// const GENERATING_TEXTFILES_KEY = 'GENERATING_TEXTFILES';
|
|
|
|
// const GENERATED_TEXTFILES_KEY = 'GENERATED_TEXTFILES';
|
|
|
|
// const GENERATING_SVGIMAGES_KEY = 'GENERATING_SVGIMAGES';
|
|
|
|
// const GENERATED_SVGIMAGES_KEY = 'GENERATED_SVGIMAGES';
|
|
|
|
// const CONVERSION_COMPLETED_KEY = 'CONVERSION_COMPLETED';
|
2017-05-06 04:17:38 +08:00
|
|
|
|
|
|
|
export default function handlePresentationConversionUpdate({ payload }) {
|
|
|
|
const meetingId = payload.meeting_id;
|
|
|
|
const presentationId = payload.presentation_id;
|
|
|
|
const status = payload.message_key;
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(presentationId, String);
|
|
|
|
check(status, String);
|
|
|
|
|
2017-06-07 20:28:41 +08:00
|
|
|
const statusModifier = {
|
2017-05-06 04:17:38 +08:00
|
|
|
'conversion.status': status,
|
2017-06-07 20:28:41 +08:00
|
|
|
'conversion.error': false,
|
2017-05-06 04:17:38 +08:00
|
|
|
'conversion.done': false,
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case SUPPORTED_DOCUMENT_KEY:
|
|
|
|
statusModifier['presentation.id'] = presentationId;
|
|
|
|
statusModifier['presentation.name'] = payload.presentation_name;
|
2017-06-07 20:28:41 +08:00
|
|
|
break;
|
2017-05-06 04:17:38 +08:00
|
|
|
|
|
|
|
case UNSUPPORTED_DOCUMENT_KEY:
|
|
|
|
case OFFICE_DOC_CONVERSION_FAILED_KEY:
|
|
|
|
case OFFICE_DOC_CONVERSION_INVALID_KEY:
|
|
|
|
case PAGE_COUNT_FAILED_KEY:
|
|
|
|
case PAGE_COUNT_EXCEEDED_KEY:
|
|
|
|
statusModifier['presentation.id'] = presentationId;
|
|
|
|
statusModifier['presentation.name'] = payload.presentation_name;
|
|
|
|
statusModifier['conversion.error'] = true;
|
2017-06-07 20:28:41 +08:00
|
|
|
break;
|
2017-05-06 04:17:38 +08:00
|
|
|
|
|
|
|
case GENERATED_SLIDE_KEY:
|
|
|
|
statusModifier['conversion.pages_completed'] = payload.pages_completed;
|
|
|
|
statusModifier['conversion.num_pages'] = payload.num_pages;
|
|
|
|
break;
|
|
|
|
|
2017-06-07 20:28:41 +08:00
|
|
|
default:
|
|
|
|
Logger.warn(`Presentation update status "${status}" not handled`);
|
2017-05-06 04:17:38 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
'presentation.id': presentationId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: Object.assign({ meetingId }, statusModifier),
|
|
|
|
};
|
|
|
|
|
|
|
|
return Presentations.upsert(selector, modifier);
|
2017-06-07 20:28:41 +08:00
|
|
|
}
|