Adapted HTML5 captions to use the recording backend
This commit is contained in:
parent
2a82aaa09f
commit
84b750ebb7
@ -0,0 +1,46 @@
|
||||
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) => {
|
||||
return 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: padId });
|
||||
|
||||
if (!pad) return Logger.error(`Editing captions history: ${padId}`);
|
||||
|
||||
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);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
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';
|
||||
|
||||
export default function editCaptions(meetingId, userId, padId) {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'UpdateCaptionOwnerPubMsg';
|
||||
|
||||
check(meetingId, String);
|
||||
check(userId, String);
|
||||
check(padId, String);
|
||||
|
||||
const pad = Captions.findOne({ meetingId: meetingId, padId: padId });
|
||||
|
||||
if (!pad) return Logger.error(`Editing captions owner: ${padId}`);
|
||||
|
||||
const { locale } = pad;
|
||||
|
||||
check(locale, { locale: String, name: String });
|
||||
|
||||
const payload = {
|
||||
ownerId: userId,
|
||||
locale: locale.name,
|
||||
localeCode: locale.locale,
|
||||
};
|
||||
|
||||
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
|
||||
}
|
@ -23,6 +23,7 @@ export default function addCaption(meetingId, padId, locale) {
|
||||
readOnlyPadId: "",
|
||||
data: "",
|
||||
revs: 0,
|
||||
length: 0,
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import Captions from '/imports/api/captions';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import updateOwner from '/imports/api/captions/server/methods/updateOwner';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export default function updateOwnerId(meetingId, userId, padId) {
|
||||
@ -22,7 +23,7 @@ export default function updateOwnerId(meetingId, userId, padId) {
|
||||
if (err) {
|
||||
return Logger.error(`Updating captions pad: ${err}`);
|
||||
}
|
||||
|
||||
updateOwner(meetingId, userId, padId);
|
||||
return Logger.verbose(`Update captions pad=${padId} ownerId=${userId}`);
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import Captions from '/imports/api/captions';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import editCaptions from '/imports/api/captions/server/methods/editCaptions';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export default function padUpdate(padId, data, revs) {
|
||||
@ -16,13 +17,16 @@ export default function padUpdate(padId, data, revs) {
|
||||
data,
|
||||
revs,
|
||||
},
|
||||
$inc: {
|
||||
length: data.length,
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) {
|
||||
return Logger.error(`Updating captions pad: ${err}`);
|
||||
}
|
||||
|
||||
editCaptions(padId, data, revs);
|
||||
return Logger.verbose(`Update captions pad=${padId} revs=${revs}`);
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,7 @@ const propTypes = {
|
||||
padId: PropTypes.string.isRequired,
|
||||
readOnlyPadId: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
amIModerator: PropTypes.bool.isRequired,
|
||||
intl: PropTypes.shape({
|
||||
formatMessage: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
@ -42,8 +43,14 @@ const Pad = (props) => {
|
||||
readOnlyPadId,
|
||||
ownerId,
|
||||
name,
|
||||
amIModerator,
|
||||
} = props;
|
||||
|
||||
if (!amIModerator) {
|
||||
Session.set('openPanel', 'userlist');
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = PadService.getPadURL(padId, readOnlyPadId, ownerId);
|
||||
|
||||
return (
|
||||
|
@ -29,5 +29,6 @@ export default withTracker(() => {
|
||||
ownerId,
|
||||
padId,
|
||||
readOnlyPadId,
|
||||
amIModerator: CaptionsService.amIModerator(),
|
||||
};
|
||||
})(PadContainer);
|
||||
|
@ -1,6 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import Captions from '/imports/api/captions';
|
||||
import Users from '/imports/api/users';
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
import mapUser from '/imports/ui/services/user/mapUser';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Session } from 'meteor/session';
|
||||
@ -125,6 +127,11 @@ const formatCaptionsText = text => {
|
||||
return filteredText.join(LINE_BREAK);
|
||||
};
|
||||
|
||||
const amIModerator = () => {
|
||||
const currentUser = Users.findOne({ userId: Auth.userID });
|
||||
return mapUser(currentUser).isModerator;
|
||||
};
|
||||
|
||||
export default {
|
||||
getCaptionsData,
|
||||
getAvailableLocales,
|
||||
@ -139,4 +146,5 @@ export default {
|
||||
deactivateCaptions,
|
||||
activateCaptions,
|
||||
formatCaptionsText,
|
||||
amIModerator,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user