您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.ts 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { IStore } from '../app/types';
  2. import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
  3. import { _authorizeDropbox } from './functions';
  4. import logger from './logger';
  5. /**
  6. * Action to authorize the Jitsi Recording app in dropbox.
  7. *
  8. * @returns {Function}
  9. */
  10. export function authorizeDropbox() {
  11. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  12. const state = getState();
  13. const { locationURL } = state['features/base/connection'];
  14. const { dropbox = { appKey: '',
  15. redirectURI: undefined } } = state['features/base/config'];
  16. // By default we use the static page on the main domain for redirection.
  17. // So we need to setup only one redirect URI in dropbox app
  18. // configuration (not multiple for all the tenants).
  19. // In case deployment is running in subfolder dropbox.redirectURI
  20. // can be configured.
  21. const redirectURI
  22. = dropbox.redirectURI || `${locationURL?.origin}/static/oauth.html`;
  23. _authorizeDropbox(dropbox.appKey, redirectURI)
  24. .then(
  25. ({ token, rToken, expireDate }) => {
  26. dispatch(updateDropboxToken(token, rToken, expireDate));
  27. })
  28. .catch(error => logger.log('Cannot authorize dropbox', error));
  29. };
  30. }
  31. /**
  32. * Action to update the dropbox access token.
  33. *
  34. * @param {string} token - The new token.
  35. * @param {string} rToken - The refresh token.
  36. * @param {number} expireDate - The token expiration date as UNIX timestamp.
  37. * @returns {{
  38. * type: UPDATE_DROPBOX_TOKEN,
  39. * token: string,
  40. * rToken: string,
  41. * expireDate: number
  42. * }}
  43. */
  44. export function updateDropboxToken(token?: string, rToken?: string, expireDate?: number) {
  45. return {
  46. type: UPDATE_DROPBOX_TOKEN,
  47. token,
  48. rToken,
  49. expireDate
  50. };
  51. }