You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.web.ts 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @ts-expect-error
  2. import { jitsiLocalStorage } from '@jitsi/js-utils';
  3. import { IStore } from '../../app/types';
  4. import { getCustomerDetails } from '../../jaas/actions.any';
  5. import { getJaasJWT, isVpaasMeeting } from '../../jaas/functions';
  6. import { showWarningNotification } from '../../notifications/actions';
  7. import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
  8. import { stopLocalVideoRecording } from '../../recording/actions.any';
  9. import LocalRecordingManager from '../../recording/components/Recording/LocalRecordingManager.web';
  10. import { setJWT } from '../jwt/actions';
  11. import { _connectInternal } from './actions.any';
  12. export * from './actions.any';
  13. /**
  14. * Opens new connection.
  15. *
  16. * @param {string} [id] - The XMPP user's ID (e.g. {@code user@server.com}).
  17. * @param {string} [password] - The XMPP user's password.
  18. * @returns {Function}
  19. */
  20. export function connect(id?: string, password?: string) {
  21. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  22. const state = getState();
  23. const { jwt } = state['features/base/jwt'];
  24. const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
  25. if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {
  26. return dispatch(getCustomerDetails())
  27. .then(() => {
  28. if (!jwt) {
  29. return getJaasJWT(state);
  30. }
  31. })
  32. .then(j => j && dispatch(setJWT(j)))
  33. .then(() => dispatch(_connectInternal(id, password)));
  34. }
  35. // used by jibri
  36. const usernameOverride = jitsiLocalStorage.getItem('xmpp_username_override');
  37. const passwordOverride = jitsiLocalStorage.getItem('xmpp_password_override');
  38. if (usernameOverride && usernameOverride.length > 0) {
  39. id = usernameOverride; // eslint-disable-line no-param-reassign
  40. }
  41. if (passwordOverride && passwordOverride.length > 0) {
  42. password = passwordOverride; // eslint-disable-line no-param-reassign
  43. }
  44. return dispatch(_connectInternal(id, password));
  45. };
  46. }
  47. /**
  48. * Closes connection.
  49. *
  50. * @param {boolean} [requestFeedback] - Whether to attempt showing a
  51. * request for call feedback.
  52. * @returns {Function}
  53. */
  54. export function hangup(requestFeedback = false) {
  55. // XXX For web based version we use conference hanging up logic from the old app.
  56. return async (dispatch: IStore['dispatch']) => {
  57. if (LocalRecordingManager.isRecordingLocally()) {
  58. dispatch(stopLocalVideoRecording());
  59. dispatch(showWarningNotification({
  60. titleKey: 'localRecording.stopping',
  61. descriptionKey: 'localRecording.wait'
  62. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  63. // wait 1000ms for the recording to end and start downloading
  64. await new Promise(res => {
  65. setTimeout(res, 1000);
  66. });
  67. }
  68. return APP.conference.hangup(requestFeedback);
  69. };
  70. }