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

actions.ts 1.7KB

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