2018-08-09 23:00:03 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-09-25 00:08:55 +00:00
|
|
|
import { getLocationContextRoot } from '../base/util';
|
2018-08-09 23:00:03 +00:00
|
|
|
|
|
|
|
import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
|
2018-09-25 00:08:55 +00:00
|
|
|
import { _authorizeDropbox } from './functions';
|
2018-08-15 19:51:51 +00:00
|
|
|
|
2018-08-09 23:00:03 +00:00
|
|
|
/**
|
|
|
|
* Action to authorize the Jitsi Recording app in dropbox.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function authorizeDropbox() {
|
|
|
|
return (dispatch: Function, getState: Function) => {
|
|
|
|
const state = getState();
|
|
|
|
const { locationURL } = state['features/base/connection'];
|
2018-09-25 00:08:55 +00:00
|
|
|
const { dropbox = {} } = state['features/base/config'];
|
2018-08-09 23:00:03 +00:00
|
|
|
const redirectURI = `${locationURL.origin
|
|
|
|
+ getLocationContextRoot(locationURL)}static/oauth.html`;
|
|
|
|
|
2018-09-26 17:57:58 +00:00
|
|
|
_authorizeDropbox(dropbox.appKey, redirectURI)
|
2018-09-25 00:08:55 +00:00
|
|
|
.then(
|
|
|
|
token => dispatch(updateDropboxToken(token)));
|
2018-08-09 23:00:03 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action to update the dropbox access token.
|
|
|
|
*
|
|
|
|
* @param {string} token - The new token.
|
|
|
|
* @returns {{
|
|
|
|
* type: UPDATE_DROPBOX_TOKEN,
|
|
|
|
* token: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function updateDropboxToken(token: string) {
|
|
|
|
return {
|
|
|
|
type: UPDATE_DROPBOX_TOKEN,
|
|
|
|
token
|
|
|
|
};
|
|
|
|
}
|