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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // @flow
  2. import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
  3. import { _authorizeDropbox } from './functions';
  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 }) => dispatch(updateDropboxToken(token, rToken, expireDate)));
  24. };
  25. }
  26. /**
  27. * Action to update the dropbox access token.
  28. *
  29. * @param {string} token - The new token.
  30. * @param {string} rToken - The refresh token.
  31. * @param {number} expireDate - The token expiration date as UNIX timestamp.
  32. * @returns {{
  33. * type: UPDATE_DROPBOX_TOKEN,
  34. * token: string,
  35. * rToken: string,
  36. * expireDate: number
  37. * }}
  38. */
  39. export function updateDropboxToken(token: string, rToken: string, expireDate: number) {
  40. return {
  41. type: UPDATE_DROPBOX_TOKEN,
  42. token,
  43. rToken,
  44. expireDate
  45. };
  46. }