You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1004B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // @flow
  2. import { Dropbox } from 'dropbox';
  3. const logger = require('jitsi-meet-logger').getLogger(__filename);
  4. /**
  5. * Fetches information about the user's dropbox account.
  6. *
  7. * @param {string} token - The dropbox access token.
  8. * @param {string} clientId - The Jitsi Recorder dropbox app ID.
  9. * @returns {Promise<Object|undefined>}
  10. */
  11. export function getDropboxData(
  12. token: string,
  13. clientId: string
  14. ): Promise<?Object> {
  15. const dropboxAPI = new Dropbox({
  16. accessToken: token,
  17. clientId
  18. });
  19. return Promise.all(
  20. [ dropboxAPI.usersGetCurrentAccount(), dropboxAPI.usersGetSpaceUsage() ]
  21. ).then(([ account, space ]) => {
  22. const { allocation, used } = space;
  23. const { allocated } = allocation;
  24. return {
  25. userName: account.name.display_name,
  26. spaceLeft: Math.floor((allocated - used) / 1048576)// 1MiB=1048576B
  27. };
  28. }, error => {
  29. logger.error(error);
  30. return undefined;
  31. });
  32. }