bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/methods/editCaptions.js
Pedro Beschorner Marin c0a7f9cd92 Replace FNV32a pad's id generator with salted SHA1
When managing Etherpad's pads, Meteor makes API calls to initiate the closed captions
and shared notes modules. The pad id was being mapped to a shorter id than the meeting
id because of a Etherpad lenght limitation.

Changed to something less guessable.
2021-02-09 12:59:59 -03:00

48 lines
1.1 KiB
JavaScript

import RedisPubSub from '/imports/startup/server/redis';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
const getIndex = (data, length) => length - data.length;
export default function editCaptions(padId, data) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'EditCaptionHistoryPubMsg';
check(padId, String);
check(data, String);
const pad = Captions.findOne({ padId });
if (!pad) {
Logger.error(`Editing captions history: ${padId}`);
return;
}
const {
meetingId,
ownerId,
locale,
length,
} = pad;
check(meetingId, String);
check(ownerId, String);
check(locale, { locale: String, name: String });
check(length, Number);
const index = getIndex(data, length);
const payload = {
startIndex: index,
localeCode: locale.locale,
locale: locale.name,
endIndex: index,
text: data,
};
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, ownerId, payload);
}