bigbluebutton-Github/bigbluebutton-html5/imports/api/common/server/helpers.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

import { logger } from '/imports/startup/server/logger';
2016-05-17 03:12:49 +08:00
import { redisPubSub } from '/imports/startup/server';
import { BREAK_LINE, CARRIAGE_RETURN, NEW_LINE } from '/imports/utils/lineEndings.js';
2016-05-13 01:43:59 +08:00
export function appendMessageHeader(eventName, messageObj) {
2016-04-20 05:16:32 +08:00
let header;
header = {
timestamp: new Date().getTime(),
name: eventName,
};
messageObj.header = header;
return messageObj;
};
export const indexOf = [].indexOf || function (item) {
2016-06-28 02:24:37 +08:00
for (let i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) {
return i;
}
}
return -1;
};
export function publish(channel, message) {
2016-10-18 20:03:51 +08:00
return redisPubSub.publish(channel, message.header.name, message.payload, message.header);
};
2016-05-13 01:43:59 +08:00
// translate '\n' newline character and '\r' carriage
// returns to '<br/>' breakline character for Flash
2016-05-17 03:12:49 +08:00
export const translateHTML5ToFlash = function (message) {
let result = message;
2016-05-13 01:43:59 +08:00
result = result.replace(new RegExp(CARRIAGE_RETURN, 'g'), BREAK_LINE);
result = result.replace(new RegExp(NEW_LINE, 'g'), BREAK_LINE);
return result;
};
2016-06-02 01:18:13 +08:00
// when requesting for history information we pass this made up requesterID
// We want to handle only the reports we requested
2016-06-28 02:24:37 +08:00
export const inReplyToHTML5Client = function (arg) {
return arg.payload.requester_id === 'nodeJSapp';
2016-06-02 01:18:13 +08:00
};