Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

functions.any.ts 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export * from './functions';
  2. import { getDisplayName, getSpaceUsage } from './functions';
  3. import logger from './logger';
  4. /**
  5. * Information related to the user's dropbox account.
  6. */
  7. type DropboxUserData = {
  8. /**
  9. * The available space left in MB into the user's Dropbox account.
  10. */
  11. spaceLeft: number;
  12. /**
  13. * The display name of the user in Dropbox.
  14. */
  15. userName: string;
  16. };
  17. /**
  18. * Fetches information about the user's dropbox account.
  19. *
  20. * @param {string} token - The dropbox access token.
  21. * @param {string} appKey - The Jitsi Recorder dropbox app key.
  22. * @returns {Promise<DropboxUserData|undefined>}
  23. */
  24. export function getDropboxData(
  25. token: string,
  26. appKey: string
  27. ): Promise<DropboxUserData | undefined> {
  28. return Promise.all(
  29. [ getDisplayName(token, appKey), getSpaceUsage(token, appKey) ]
  30. ).then(([ userName, space ]) => {
  31. const { allocated, used } = space;
  32. return {
  33. userName,
  34. spaceLeft: Math.floor((allocated - used) / 1048576)// 1MiB=1048576B
  35. };
  36. }, error => {
  37. logger.error(error);
  38. return undefined;
  39. });
  40. }