Merge pull request #11848 from antobinary/apr1-merge

Merged 2.2.36 into 2.3-beta
This commit is contained in:
Anton Georgiev 2021-04-01 14:21:07 -04:00 committed by GitHub
commit 6cc4a8a317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 84 additions and 53 deletions

View File

@ -509,7 +509,7 @@ class SIPSession {
callerIdName: this.user.callerIdName, callerIdName: this.user.callerIdName,
}, },
}, 'User agent disconnected: trying to reconnect...' }, 'User agent disconnected: trying to reconnect...'
+ ` (userHangup = ${!!this.userRequestedHangup})`); + ` (userHangup = ${!!this.userRequestedHangup})`);
logger.info({ logger.info({
logCode: 'sip_js_session_ua_reconnecting', logCode: 'sip_js_session_ua_reconnecting',
@ -605,7 +605,7 @@ class SIPSession {
callerIdName: this.user.callerIdName, callerIdName: this.user.callerIdName,
}, },
}, 'User agent failed to reconnect after' }, 'User agent failed to reconnect after'
+ ` ${USER_AGENT_RECONNECTION_ATTEMPTS} attemps`); + ` ${USER_AGENT_RECONNECTION_ATTEMPTS} attemps`);
this.callback({ this.callback({
status: this.baseCallStates.failed, status: this.baseCallStates.failed,
@ -879,7 +879,7 @@ class SIPSession {
callerIdName: this.user.callerIdName, callerIdName: this.user.callerIdName,
}, },
}, 'ICE connection state change - Current connection state - ' }, 'ICE connection state change - Current connection state - '
+ `${peer.connectionState}`); + `${peer.connectionState}`);
switch (peer.connectionState) { switch (peer.connectionState) {
case 'failed': case 'failed':
@ -904,8 +904,8 @@ class SIPSession {
callerIdName: this.user.callerIdName, callerIdName: this.user.callerIdName,
}, },
}, 'ICE connection success, but user is already connected' }, 'ICE connection success, but user is already connected'
+ 'ignoring it...' + 'ignoring it...'
+ `${peer.iceConnectionState}`); + `${peer.iceConnectionState}`);
return; return;
} }
@ -917,7 +917,7 @@ class SIPSession {
callerIdName: this.user.callerIdName, callerIdName: this.user.callerIdName,
}, },
}, 'ICE connection success. Current ICE Connection state - ' }, 'ICE connection success. Current ICE Connection state - '
+ `${peer.iceConnectionState}`); + `${peer.iceConnectionState}`);
clearTimeout(callTimeout); clearTimeout(callTimeout);
clearTimeout(iceNegotiationTimeout); clearTimeout(iceNegotiationTimeout);
@ -1219,7 +1219,7 @@ export default class SIPBridge extends BaseAudioBridge {
let shouldTryReconnect = false; let shouldTryReconnect = false;
// Try and get the call to clean up and end on an error // Try and get the call to clean up and end on an error
this.activeSession.exitAudio().catch(() => {}); this.activeSession.exitAudio().catch(() => { });
if (this.activeSession.webrtcConnected) { if (this.activeSession.webrtcConnected) {
// webrtc was able to connect so just try again // webrtc was able to connect so just try again

View File

@ -1,5 +1,5 @@
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { hashSHA1 } from '/imports/api/common/server/helpers'; import { hashSHA1 } from '/imports/api/common/server/etherpad';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
const ETHERPAD = Meteor.settings.private.etherpad; const ETHERPAD = Meteor.settings.private.etherpad;

View File

@ -1,12 +1,8 @@
import axios from 'axios'; import axios from 'axios';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger'; import Logger from '/imports/startup/server/logger';
import { import { generatePadId } from '/imports/api/captions/server/helpers';
generatePadId, import { appendTextURL } from '/imports/api/common/server/etherpad';
} from '/imports/api/captions/server/helpers';
import {
appendTextURL,
} from '/imports/api/note/server/helpers';
import { extractCredentials } from '/imports/api/common/server/helpers'; import { extractCredentials } from '/imports/api/common/server/helpers';
export default function appendText(text, locale) { export default function appendText(text, locale) {

View File

@ -5,7 +5,7 @@ import {
isEnabled, isEnabled,
getLocalesURL, getLocalesURL,
} from '/imports/api/captions/server/helpers'; } from '/imports/api/captions/server/helpers';
import { withInstaceId } from '/imports/api/note/server/helpers'; import { withInstaceId } from '/imports/api/common/server/etherpad';
import addCaption from '/imports/api/captions/server/modifiers/addCaption'; import addCaption from '/imports/api/captions/server/modifiers/addCaption';
import addCaptionsPads from '/imports/api/captions/server/methods/addCaptionsPads'; import addCaptionsPads from '/imports/api/captions/server/methods/addCaptionsPads';
import axios from 'axios'; import axios from 'axios';
@ -13,7 +13,7 @@ import axios from 'axios';
export default function createCaptions(meetingId, instanceId) { export default function createCaptions(meetingId, instanceId) {
// Avoid captions creation if this feature is disabled // Avoid captions creation if this feature is disabled
if (!isEnabled()) { if (!isEnabled()) {
Logger.warn(`Captions are disabled for ${meetingId}`); Logger.warn(`Closed captions are disabled`);
return; return;
} }

View File

@ -1,20 +1,16 @@
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger'; import Logger from '/imports/startup/server/logger';
import { import { getReadOnlyIdURL } from '/imports/api/common/server/etherpad';
getReadOnlyIdURL, import { getDataFromResponse } from '/imports/api/note/server/helpers';
getDataFromResponse,
} from '/imports/api/note/server/helpers';
import updateReadOnlyPadId from '/imports/api/captions/server/modifiers/updateReadOnlyPadId'; import updateReadOnlyPadId from '/imports/api/captions/server/modifiers/updateReadOnlyPadId';
import axios from 'axios'; import axios from 'axios';
export default function fetchReadOnlyPadId(padId) { export default function fetchReadOnlyPadId(padId) {
check(padId, String); check(padId, String);
const readOnlyURL = getReadOnlyIdURL(padId);
axios({ axios({
method: 'get', method: 'get',
url: readOnlyURL, url: getReadOnlyIdURL(padId),
responseType: 'json', responseType: 'json',
}).then((response) => { }).then((response) => {
const { status } = response; const { status } = response;

View File

@ -0,0 +1,52 @@
import axios from 'axios';
import sha1 from 'crypto-js/sha1';
import Logger from '/imports/startup/server/logger';
import createNote from '/imports/api/note/server/methods/createNote';
import createCaptions from '/imports/api/captions/server/methods/createCaptions';
const ETHERPAD = Meteor.settings.private.etherpad;
const BASE_URL = `http://${ETHERPAD.host}:${ETHERPAD.port}/api/${ETHERPAD.version}`;
const createPadURL = padId => `${BASE_URL}/createPad?apikey=${ETHERPAD.apikey}&padID=${padId}`;
const getReadOnlyIdURL = padId => `${BASE_URL}/getReadOnlyID?apikey=${ETHERPAD.apikey}&padID=${padId}`;
const appendTextURL = (padId, text) => `${BASE_URL}/appendText?apikey=${ETHERPAD.apikey}&padID=${padId}&text=${encodeURIComponent(text)}`;
const checkTokenURL = () => `${BASE_URL}/checkToken?apikey=${ETHERPAD.apikey}`;
const hashSHA1 = (str) => sha1(str).toString();
const checkServer = () => {
return new Promise((resolve, reject) => {
axios({
method: 'get',
url: checkTokenURL(),
responseType: 'json',
}).then((response) => {
const { status } = response;
if (status !== 200) return reject();
const { message } = response.data;
if (message !== 'ok') return reject();
resolve();
}).catch(() => reject());
});
};
const initPads = (meetingId, html5InstanceId) => {
checkServer().then(() => {
createNote(meetingId, html5InstanceId);
createCaptions(meetingId, html5InstanceId);
}).catch(() => Logger.error(`Pads' server unreachable`));
};
const withInstaceId = (instanceId, id) => `[${instanceId}]${id}`;
export {
hashSHA1,
createPadURL,
getReadOnlyIdURL,
appendTextURL,
initPads,
withInstaceId,
}

View File

@ -1,4 +1,3 @@
import sha1 from 'crypto-js/sha1';
import Users from '/imports/api/users'; import Users from '/imports/api/users';
const MSG_DIRECT_TYPE = 'DIRECT'; const MSG_DIRECT_TYPE = 'DIRECT';
@ -39,8 +38,6 @@ export const processForHTML5ServerOnly = fn => (message, ...args) => {
return fn(message, ...args); return fn(message, ...args);
}; };
export const hashSHA1 = (str) => sha1(str).toString();
export const extractCredentials = (credentials) => { export const extractCredentials = (credentials) => {
if (!credentials) return {}; if (!credentials) return {};
const credentialsArray = credentials.split('--'); const credentialsArray = credentials.split('--');

View File

@ -6,8 +6,7 @@ import {
import SanitizeHTML from 'sanitize-html'; import SanitizeHTML from 'sanitize-html';
import Meetings, { RecordMeetings } from '/imports/api/meetings'; import Meetings, { RecordMeetings } from '/imports/api/meetings';
import Logger from '/imports/startup/server/logger'; import Logger from '/imports/startup/server/logger';
import createNote from '/imports/api/note/server/methods/createNote'; import { initPads } from '/imports/api/common/server/etherpad';
import createCaptions from '/imports/api/captions/server/methods/createCaptions';
import { addAnnotationsStreamer } from '/imports/api/annotations/server/streamer'; import { addAnnotationsStreamer } from '/imports/api/annotations/server/streamer';
import { addCursorStreamer } from '/imports/api/cursor/server/streamer'; import { addCursorStreamer } from '/imports/api/cursor/server/streamer';
import { addExternalVideoStreamer } from '/imports/api/external-videos/server/streamer'; import { addExternalVideoStreamer } from '/imports/api/external-videos/server/streamer';
@ -184,8 +183,7 @@ export default function addMeeting(meeting) {
Logger.info(`Added meeting id=${meetingId}`); Logger.info(`Added meeting id=${meetingId}`);
const { html5InstanceId } = meeting.systemProps; const { html5InstanceId } = meeting.systemProps;
createNote(meetingId, html5InstanceId); initPads(meetingId, html5InstanceId);
createCaptions(meetingId, html5InstanceId);
} else if (numberAffected) { } else if (numberAffected) {
Logger.info(`Upserted meeting id=${meetingId}`); Logger.info(`Upserted meeting id=${meetingId}`);
} }

View File

@ -1,21 +1,10 @@
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { hashSHA1 } from '/imports/api/common/server/helpers'; import { hashSHA1 } from '/imports/api/common/server/etherpad';
const ETHERPAD = Meteor.settings.private.etherpad; const ETHERPAD = Meteor.settings.private.etherpad;
const NOTE_CONFIG = Meteor.settings.public.note; const NOTE_CONFIG = Meteor.settings.public.note;
const BASE_URL = `http://${ETHERPAD.host}:${ETHERPAD.port}/api/${ETHERPAD.version}`;
const TOKEN = '_'; const TOKEN = '_';
const createPadURL = padId => `${BASE_URL}/createPad?apikey=${ETHERPAD.apikey}&padID=${padId}`;
const getReadOnlyIdURL = padId => `${BASE_URL}/getReadOnlyID?apikey=${ETHERPAD.apikey}&padID=${padId}`;
const appendTextURL = (padId, text) => `${BASE_URL}/appendText?apikey=${ETHERPAD.apikey}&padID=${padId}&text=${encodeURIComponent(text)}`;
const generateNoteId = (meetingId) => hashSHA1(meetingId+ETHERPAD.apikey);
const withInstaceId = (instanceId, id) => `[${instanceId}]${id}`;
const isEnabled = () => NOTE_CONFIG.enabled; const isEnabled = () => NOTE_CONFIG.enabled;
const getDataFromResponse = (data, key) => { const getDataFromResponse = (data, key) => {
@ -38,16 +27,14 @@ const processForNotePadOnly = fn => (message, ...args) => {
check(id, String); check(id, String);
if (isNotePad(id)) return fn(message, ...args); if (isNotePad(id)) return fn(message, ...args);
return () => {}; return () => { };
}; };
const generatePadId = meetingId => hashSHA1(meetingId + ETHERPAD.apikey);
export { export {
generateNoteId, generatePadId,
createPadURL,
getReadOnlyIdURL,
isEnabled, isEnabled,
getDataFromResponse, getDataFromResponse,
appendTextURL,
processForNotePadOnly, processForNotePadOnly,
withInstaceId,
}; };

View File

@ -1,12 +1,14 @@
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger'; import Logger from '/imports/startup/server/logger';
import { import {
generateNoteId,
createPadURL, createPadURL,
getReadOnlyIdURL, getReadOnlyIdURL,
withInstaceId,
} from '/imports/api/common/server/etherpad';
import {
generatePadId,
isEnabled, isEnabled,
getDataFromResponse, getDataFromResponse,
withInstaceId,
} from '/imports/api/note/server/helpers'; } from '/imports/api/note/server/helpers';
import addNote from '/imports/api/note/server/modifiers/addNote'; import addNote from '/imports/api/note/server/modifiers/addNote';
import axios from 'axios'; import axios from 'axios';
@ -14,14 +16,14 @@ import axios from 'axios';
export default function createNote(meetingId, instanceId) { export default function createNote(meetingId, instanceId) {
// Avoid note creation if this feature is disabled // Avoid note creation if this feature is disabled
if (!isEnabled()) { if (!isEnabled()) {
Logger.warn(`Notes are disabled for ${meetingId}`); Logger.warn(`Shared notes are disabled`);
return; return;
} }
check(meetingId, String); check(meetingId, String);
check(instanceId, Number); check(instanceId, Number);
const noteId = withInstaceId(instanceId, generateNoteId(meetingId)); const noteId = withInstaceId(instanceId, generatePadId(meetingId));
const createURL = createPadURL(noteId); const createURL = createPadURL(noteId);

View File

@ -118,7 +118,10 @@ const getCaptionsSettings = () => {
return settings; return settings;
}; };
const isCaptionsEnabled = () => CAPTIONS_CONFIG.enabled; const isCaptionsEnabled = () => {
const captions = Captions.findOne({ meetingId: Auth.meetingID });
return CAPTIONS_CONFIG.enabled && captions;
};
const isCaptionsAvailable = () => { const isCaptionsAvailable = () => {
if (isCaptionsEnabled) { if (isCaptionsEnabled) {