diff --git a/bigbluebutton-html5/imports/api/captions/server/methods/appendText.js b/bigbluebutton-html5/imports/api/captions/server/methods/appendText.js index d4306af28911e38fd447742e1f5881d3c6dd2b58..be364842d87a42c69b0ed15de20781cdc33dbcdb 100644 --- a/bigbluebutton-html5/imports/api/captions/server/methods/appendText.js +++ b/bigbluebutton-html5/imports/api/captions/server/methods/appendText.js @@ -1,18 +1,30 @@ import axios from 'axios'; import { check } from 'meteor/check'; import Logger from '/imports/startup/server/logger'; -import { generatePadId } from '/imports/api/captions/server/helpers'; +import Captions from '/imports/api/captions'; +import { CAPTIONS_TOKEN } from '/imports/api/captions/server/helpers'; import { appendTextURL } from '/imports/api/common/server/etherpad'; import { extractCredentials } from '/imports/api/common/server/helpers'; export default function appendText(text, locale) { try { const { meetingId } = extractCredentials(this.userId); + check(meetingId, String); check(text, String); check(locale, String); - const padId = generatePadId(meetingId, locale); + const captions = Captions.findOne({ + meetingId, + padId: { $regex: `${CAPTIONS_TOKEN}${locale}$` }, + }); + + if (!captions) { + Logger.error(`Could not find captions' pad for meetingId=${meetingId} locale=${locale}`); + return; + } + + const { padId } = captions; axios({ method: 'get', diff --git a/bigbluebutton-html5/imports/api/captions/server/methods/editCaptions.js b/bigbluebutton-html5/imports/api/captions/server/methods/editCaptions.js index 8b62167b9e96a6efd8c30e744c893401e952dcaa..f12ba4c2c6a6310f3cbf4855b2bf9399d0d47160 100644 --- a/bigbluebutton-html5/imports/api/captions/server/methods/editCaptions.js +++ b/bigbluebutton-html5/imports/api/captions/server/methods/editCaptions.js @@ -13,13 +13,10 @@ export default function editCaptions(padId, data) { const EVENT_NAME = 'EditCaptionHistoryPubMsg'; try { - const { meetingId } = extractCredentials(this.userId); - check(padId, String); check(data, String); - check(meetingId, String); - const pad = Captions.findOne({ padId, meetingId }); + const pad = Captions.findOne({ padId }); if (!pad) { Logger.error(`Editing captions history: ${padId}`); @@ -27,11 +24,13 @@ export default function editCaptions(padId, data) { } const { + meetingId, ownerId, locale, length, } = pad; + check(meetingId, String); check(ownerId, String); check(locale, { locale: String, name: String }); check(length, Number); diff --git a/bigbluebutton-html5/imports/ui/components/captions/service.js b/bigbluebutton-html5/imports/ui/components/captions/service.js index b1b00b7e86a5ef42ca9cd9fd7e8d44e3da8f421a..4281249f98403855506124c6e4f35f520a325366 100644 --- a/bigbluebutton-html5/imports/ui/components/captions/service.js +++ b/bigbluebutton-html5/imports/ui/components/captions/service.js @@ -69,14 +69,11 @@ const takeOwnership = (locale) => { makeCall('takeOwnership', locale); }; -const formatEntry = (entry) => { - const letterIndex = entry.charAt(0) === ' ' ? 1 : 0; - const formattedEntry = `${entry.charAt(letterIndex).toUpperCase() + entry.slice(letterIndex + 1)}.\n\n`; - return formattedEntry; -}; - const appendText = (text, locale) => { - makeCall('appendText', formatEntry(text), locale); + if (typeof text !== 'string' || text.length === 0) return; + + const formattedText = `${text.trim().replace(/^\w/, (c) => c.toUpperCase())}\n\n`; + makeCall('appendText', formattedText, locale); }; const canIOwnThisPad = (ownerId) => {