2022-04-01 03:40:07 +08:00
|
|
|
import setTranscript from '/imports/api/audio-captions/server/modifiers/setTranscript';
|
2023-11-30 23:10:36 +08:00
|
|
|
import updateTranscriptPad from '/imports/api/pads/server/methods/updateTranscriptPad';
|
|
|
|
import Users from '/imports/api/users';
|
|
|
|
|
|
|
|
const TRANSCRIPTION_DEFAULT_PAD = Meteor.settings.public.captions.defaultPad;
|
|
|
|
|
|
|
|
const formatDate = (dStr) => {
|
|
|
|
return ("00" + dStr).substr(-2,2);
|
|
|
|
};
|
2022-04-01 03:40:07 +08:00
|
|
|
|
2023-03-13 21:11:04 +08:00
|
|
|
export default async function transcriptUpdated({ header, body }) {
|
2023-11-30 23:10:36 +08:00
|
|
|
const {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
} = header;
|
2022-04-01 03:40:07 +08:00
|
|
|
|
2022-04-13 23:00:45 +08:00
|
|
|
const {
|
|
|
|
transcriptId,
|
|
|
|
transcript,
|
2023-11-30 23:10:36 +08:00
|
|
|
locale,
|
|
|
|
result,
|
2022-04-13 23:00:45 +08:00
|
|
|
} = body;
|
2022-04-01 03:40:07 +08:00
|
|
|
|
2023-11-30 23:10:36 +08:00
|
|
|
if (result) {
|
|
|
|
const user = Users.findOne({ userId }, { fields: { name: 1 } });
|
|
|
|
const userName = user?.name || '??';
|
|
|
|
|
|
|
|
const dt = new Date(Date.now());
|
|
|
|
const hours = formatDate(dt.getHours()),
|
|
|
|
minutes = formatDate(dt.getMinutes()),
|
|
|
|
seconds = formatDate(dt.getSeconds());
|
|
|
|
|
|
|
|
const userSpoke = `\n ${userName} (${hours}:${minutes}:${seconds}): ${transcript}`;
|
|
|
|
updateTranscriptPad(meetingId, userId, TRANSCRIPTION_DEFAULT_PAD, userSpoke);
|
|
|
|
}
|
|
|
|
|
|
|
|
await setTranscript(userId, meetingId, transcriptId, transcript, locale);
|
2022-04-01 03:40:07 +08:00
|
|
|
}
|