Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

actions.js 1.7KB

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