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.

middleware.web.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { redirectToStaticPage } from '../app/actions';
  2. import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
  3. import { CONNECTION_FAILED } from '../base/connection';
  4. import { JitsiConnectionErrors } from '../base/lib-jitsi-meet';
  5. import { MiddlewareRegistry } from '../base/redux';
  6. import { SET_DETAILS } from './actionTypes';
  7. import { getCustomerDetails } from './actions';
  8. import { STATUSES } from './constants';
  9. import { isVpaasMeeting } from './functions';
  10. /**
  11. * The redux middleware for jaas.
  12. *
  13. * @param {Store} store - The redux store.
  14. * @returns {Function}
  15. */
  16. MiddlewareRegistry.register(store => next => async action => {
  17. switch (action.type) {
  18. case CONFERENCE_JOINED: {
  19. store.dispatch(getCustomerDetails());
  20. break;
  21. }
  22. case CONNECTION_FAILED: {
  23. const { error } = action;
  24. if (!isVpaasMeeting(store.getState()) || !error) {
  25. break;
  26. }
  27. if (error.name === JitsiConnectionErrors.PASSWORD_REQUIRED) {
  28. if (error.message !== 'could not obtain public key') {
  29. break;
  30. }
  31. store.dispatch(redirectToStaticPage('/static/planLimit.html'));
  32. }
  33. break;
  34. }
  35. case SET_DETAILS: {
  36. const { status } = action.payload;
  37. if (status === STATUSES.BLOCKED) {
  38. store.dispatch(redirectToStaticPage('/static/planLimit.html'));
  39. }
  40. }
  41. }
  42. return next(action);
  43. });