mirror of https://github.com/jitsi/jitsi-meet
parent
62544188bd
commit
2704b2f822
@ -1,29 +0,0 @@ |
||||
// @flow
|
||||
|
||||
import { getJitsiMeetGlobalNS } from '../util'; |
||||
|
||||
|
||||
/** |
||||
* Executes the oauth flow. |
||||
* |
||||
* @param {string} authUrl - The URL to oauth service. |
||||
* @returns {Promise<string>} - The URL with the authorization details. |
||||
*/ |
||||
export function authorize(authUrl: string): Promise<string> { |
||||
const windowName = `oauth${Date.now()}`; |
||||
const gloabalNS = getJitsiMeetGlobalNS(); |
||||
|
||||
gloabalNS.oauthCallbacks = gloabalNS.oauthCallbacks || {}; |
||||
|
||||
return new Promise(resolve => { |
||||
const popup = window.open(authUrl, windowName); |
||||
|
||||
gloabalNS.oauthCallbacks[windowName] = () => { |
||||
const returnURL = popup.location.href; |
||||
|
||||
popup.close(); |
||||
delete gloabalNS.oauthCallbacks.windowName; |
||||
resolve(returnURL); |
||||
}; |
||||
}); |
||||
} |
@ -1,38 +0,0 @@ |
||||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../redux'; |
||||
import { PersistenceRegistry } from '../storage'; |
||||
|
||||
import { UPDATE_DROPBOX_TOKEN } from './actionTypes'; |
||||
|
||||
/** |
||||
* The default state. |
||||
*/ |
||||
const DEFAULT_STATE = { |
||||
dropbox: {} |
||||
}; |
||||
|
||||
/** |
||||
* The redux subtree of this feature. |
||||
*/ |
||||
const STORE_NAME = 'features/base/oauth'; |
||||
|
||||
/** |
||||
* Sets up the persistence of the feature {@code oauth}. |
||||
*/ |
||||
PersistenceRegistry.register(STORE_NAME); |
||||
|
||||
ReducerRegistry.register('features/base/oauth', |
||||
(state = DEFAULT_STATE, action) => { |
||||
switch (action.type) { |
||||
case UPDATE_DROPBOX_TOKEN: |
||||
return { |
||||
...state, |
||||
dropbox: { |
||||
token: action.token |
||||
} |
||||
}; |
||||
default: |
||||
return state; |
||||
} |
||||
}); |
@ -0,0 +1,39 @@ |
||||
// @flow
|
||||
|
||||
import { Dropbox } from 'dropbox'; |
||||
|
||||
const logger = require('jitsi-meet-logger').getLogger(__filename); |
||||
|
||||
/** |
||||
* Fetches information about the user's dropbox account. |
||||
* |
||||
* @param {string} token - The dropbox access token. |
||||
* @param {string} clientId - The Jitsi Recorder dropbox app ID. |
||||
* @returns {Promise<Object|undefined>} |
||||
*/ |
||||
export function getDropboxData( |
||||
token: string, |
||||
clientId: string |
||||
): Promise<?Object> { |
||||
const dropboxAPI = new Dropbox({ |
||||
accessToken: token, |
||||
clientId |
||||
}); |
||||
|
||||
return Promise.all( |
||||
[ dropboxAPI.usersGetCurrentAccount(), dropboxAPI.usersGetSpaceUsage() ] |
||||
).then(([ account, space ]) => { |
||||
const { allocation, used } = space; |
||||
const { allocated } = allocation; |
||||
|
||||
return { |
||||
userName: account.name.display_name, |
||||
spaceLeft: Math.floor((allocated - used) / 1048576)// 1MiB=1048576B
|
||||
}; |
||||
|
||||
}, error => { |
||||
logger.error(error); |
||||
|
||||
return undefined; |
||||
}); |
||||
} |
@ -1,3 +1,4 @@ |
||||
export * from './actions'; |
||||
export * from './functions'; |
||||
|
||||
import './reducer'; |
@ -0,0 +1,28 @@ |
||||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../base/redux'; |
||||
import { PersistenceRegistry } from '../base/storage'; |
||||
|
||||
import { UPDATE_DROPBOX_TOKEN } from './actionTypes'; |
||||
|
||||
/** |
||||
* The redux subtree of this feature. |
||||
*/ |
||||
const STORE_NAME = 'features/dropbox'; |
||||
|
||||
/** |
||||
* Sets up the persistence of the feature {@code dropbox}. |
||||
*/ |
||||
PersistenceRegistry.register(STORE_NAME); |
||||
|
||||
ReducerRegistry.register(STORE_NAME, (state = {}, action) => { |
||||
switch (action.type) { |
||||
case UPDATE_DROPBOX_TOKEN: |
||||
return { |
||||
...state, |
||||
token: action.token |
||||
}; |
||||
default: |
||||
return state; |
||||
} |
||||
}); |
Loading…
Reference in new issue