ref(dropbox): Consistency for the naming around the app key.
This commit is contained in:
committed by
Любомир Маринов
parent
467452d110
commit
60decf7692
@@ -18,7 +18,7 @@ export function authorizeDropbox() {
|
||||
const redirectURI = `${locationURL.origin
|
||||
+ getLocationContextRoot(locationURL)}static/oauth.html`;
|
||||
|
||||
_authorizeDropbox(dropbox.clientId, redirectURI)
|
||||
_authorizeDropbox(dropbox.appKey, redirectURI)
|
||||
.then(
|
||||
token => dispatch(updateDropboxToken(token)));
|
||||
};
|
||||
|
||||
@@ -25,15 +25,15 @@ type DropboxUserData = {
|
||||
* Fetches information about the user's dropbox account.
|
||||
*
|
||||
* @param {string} token - The dropbox access token.
|
||||
* @param {string} clientId - The Jitsi Recorder dropbox app ID.
|
||||
* @param {string} appKey - The Jitsi Recorder dropbox app key.
|
||||
* @returns {Promise<DropboxUserData|undefined>}
|
||||
*/
|
||||
export function getDropboxData(
|
||||
token: string,
|
||||
clientId: string
|
||||
appKey: string
|
||||
): Promise<?DropboxUserData> {
|
||||
return Promise.all(
|
||||
[ getDisplayName(token, clientId), getSpaceUsage(token, clientId) ]
|
||||
[ getDisplayName(token, appKey), getSpaceUsage(token, appKey) ]
|
||||
).then(([ userName, space ]) => {
|
||||
const { allocated, used } = space;
|
||||
|
||||
|
||||
@@ -4,6 +4,18 @@ import { NativeModules } from 'react-native';
|
||||
|
||||
const { Dropbox } = NativeModules;
|
||||
|
||||
/**
|
||||
* Action to authorize the Jitsi Recording app in dropbox.
|
||||
*
|
||||
* @param {string} appKey - The Jitsi Recorder dropbox app key.
|
||||
* @param {string} redirectURI - The return URL.
|
||||
* @returns {Promise<string>} - The promise will be resolved with the dropbox
|
||||
* access token or rejected with an error.
|
||||
*/
|
||||
export function _authorizeDropbox(): Promise<string> {
|
||||
return Dropbox.authorize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the current dropbox account.
|
||||
*
|
||||
@@ -28,19 +40,6 @@ export function getSpaceUsage(token: string) {
|
||||
return Dropbox.getSpaceUsage(token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action to authorize the Jitsi Recording app in dropbox.
|
||||
*
|
||||
* @param {string} clientId - The Jitsi Recorder dropbox app ID.
|
||||
* @param {string} redirectURI - The return URL.
|
||||
* @returns {Promise<string>} - The promise will be resolved with the dropbox
|
||||
* access token or rejected with an error.
|
||||
*/
|
||||
export function _authorizeDropbox(): Promise<string> {
|
||||
return Dropbox.authorize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
|
||||
* otherwise.
|
||||
|
||||
@@ -2,54 +2,11 @@
|
||||
|
||||
import { Dropbox } from 'dropbox';
|
||||
|
||||
import { parseURLParams } from '../base/config';
|
||||
import {
|
||||
getJitsiMeetGlobalNS,
|
||||
parseStandardURIString
|
||||
} from '../base/util';
|
||||
import { parseURLParams } from '../base/config';
|
||||
|
||||
/**
|
||||
* Returns the display name for the current dropbox account.
|
||||
*
|
||||
* @param {string} token - The dropbox access token.
|
||||
* @param {string} clientId - The Jitsi Recorder dropbox app ID.
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export function getDisplayName(token: string, clientId: string) {
|
||||
const dropboxAPI = new Dropbox({
|
||||
accessToken: token,
|
||||
clientId
|
||||
});
|
||||
|
||||
return (
|
||||
dropboxAPI.usersGetCurrentAccount()
|
||||
.then(account => account.name.display_name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the space usage for the current dropbox account.
|
||||
*
|
||||
* @param {string} token - The dropbox access token.
|
||||
* @param {string} clientId - The Jitsi Recorder dropbox app ID.
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
export function getSpaceUsage(token: string, clientId: string) {
|
||||
const dropboxAPI = new Dropbox({
|
||||
accessToken: token,
|
||||
clientId
|
||||
});
|
||||
|
||||
return dropboxAPI.usersGetSpaceUsage().then(space => {
|
||||
const { allocation, used } = space;
|
||||
const { allocated } = allocation;
|
||||
|
||||
return {
|
||||
used,
|
||||
allocated
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes the oauth flow.
|
||||
@@ -79,15 +36,15 @@ function authorize(authUrl: string): Promise<string> {
|
||||
/**
|
||||
* Action to authorize the Jitsi Recording app in dropbox.
|
||||
*
|
||||
* @param {string} clientId - The Jitsi Recorder dropbox app ID.
|
||||
* @param {string} appKey - The Jitsi Recorder dropbox app key.
|
||||
* @param {string} redirectURI - The return URL.
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export function _authorizeDropbox(
|
||||
clientId: string,
|
||||
appKey: string,
|
||||
redirectURI: string
|
||||
): Promise<string> {
|
||||
const dropboxAPI = new Dropbox({ clientId });
|
||||
const dropboxAPI = new Dropbox({ clientId: appKey });
|
||||
const url = dropboxAPI.getAuthenticationUrl(redirectURI);
|
||||
|
||||
return authorize(url).then(returnUrl => {
|
||||
@@ -98,6 +55,48 @@ export function _authorizeDropbox(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the current dropbox account.
|
||||
*
|
||||
* @param {string} token - The dropbox access token.
|
||||
* @param {string} appKey - The Jitsi Recorder dropbox app key.
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export function getDisplayName(token: string, appKey: string) {
|
||||
const dropboxAPI = new Dropbox({
|
||||
accessToken: token,
|
||||
clientId: appKey
|
||||
});
|
||||
|
||||
return (
|
||||
dropboxAPI.usersGetCurrentAccount()
|
||||
.then(account => account.name.display_name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the space usage for the current dropbox account.
|
||||
*
|
||||
* @param {string} token - The dropbox access token.
|
||||
* @param {string} appKey - The Jitsi Recorder dropbox app key.
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
export function getSpaceUsage(token: string, appKey: string) {
|
||||
const dropboxAPI = new Dropbox({
|
||||
accessToken: token,
|
||||
clientId: appKey
|
||||
});
|
||||
|
||||
return dropboxAPI.usersGetSpaceUsage().then(space => {
|
||||
const { allocation, used } = space;
|
||||
const { allocated } = allocation;
|
||||
|
||||
return {
|
||||
allocated,
|
||||
used
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
|
||||
* otherwise.
|
||||
@@ -108,5 +107,5 @@ export function _authorizeDropbox(
|
||||
export function isEnabled(state: Object) {
|
||||
const { dropbox = {} } = state['features/base/config'];
|
||||
|
||||
return typeof dropbox.clientId === 'string';
|
||||
return typeof dropbox.appKey === 'string';
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ type Props = {
|
||||
_conference: Object,
|
||||
|
||||
/**
|
||||
* The client id for the dropbox authentication.
|
||||
* The app key for the dropbox authentication.
|
||||
*/
|
||||
_clientId: string,
|
||||
_appKey: string,
|
||||
|
||||
/**
|
||||
* The dropbox access token.
|
||||
@@ -117,7 +117,7 @@ class StartRecordingDialog extends Component<Props, State> {
|
||||
* @returns {void}
|
||||
*/
|
||||
_onTokenUpdated() {
|
||||
const { _clientId, _token } = this.props;
|
||||
const { _appKey, _token } = this.props;
|
||||
|
||||
if (typeof _token === 'undefined') {
|
||||
this.setState({
|
||||
@@ -129,7 +129,7 @@ class StartRecordingDialog extends Component<Props, State> {
|
||||
isTokenValid: false,
|
||||
isValidating: true
|
||||
});
|
||||
getDropboxData(_token, _clientId).then(data => {
|
||||
getDropboxData(_token, _appKey).then(data => {
|
||||
if (typeof data === 'undefined') {
|
||||
this.setState({
|
||||
isTokenValid: false,
|
||||
@@ -216,7 +216,7 @@ class StartRecordingDialog extends Component<Props, State> {
|
||||
* @param {Object} state - The Redux state.
|
||||
* @private
|
||||
* @returns {{
|
||||
* _clientId: string,
|
||||
* _appKey: string,
|
||||
* _conference: JitsiConference,
|
||||
* _token: string
|
||||
* }}
|
||||
@@ -225,7 +225,7 @@ function mapStateToProps(state: Object) {
|
||||
const { dropbox = {} } = state['features/base/config'];
|
||||
|
||||
return {
|
||||
_clientId: dropbox.clientId,
|
||||
_appKey: dropbox.appKey,
|
||||
_conference: state['features/base/conference'].conference,
|
||||
_token: state['features/dropbox'].token
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user