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

functions.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // @flow
  2. import { Dropbox } from 'dropbox';
  3. import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
  4. const logger = require('jitsi-meet-logger').getLogger(__filename);
  5. /**
  6. * Searches in the passed in redux state for an active recording session of the
  7. * passed in mode.
  8. *
  9. * @param {Object} state - The redux state to search in.
  10. * @param {string} mode - Find an active recording session of the given mode.
  11. * @returns {Object|undefined}
  12. */
  13. export function getActiveSession(state: Object, mode: string) {
  14. const { sessionDatas } = state['features/recording'];
  15. const { status: statusConstants } = JitsiRecordingConstants;
  16. return sessionDatas.find(sessionData => sessionData.mode === mode
  17. && (sessionData.status === statusConstants.ON
  18. || sessionData.status === statusConstants.PENDING));
  19. }
  20. /**
  21. * Searches in the passed in redux state for a recording session that matches
  22. * the passed in recording session ID.
  23. *
  24. * @param {Object} state - The redux state to search in.
  25. * @param {string} id - The ID of the recording session to find.
  26. * @returns {Object|undefined}
  27. */
  28. export function getSessionById(state: Object, id: string) {
  29. return state['features/recording'].sessionDatas.find(
  30. sessionData => sessionData.id === id);
  31. }
  32. /**
  33. * Fetches information about the user's dropbox account.
  34. *
  35. * @param {string} token - The dropbox access token.
  36. * @param {string} clientId - The Jitsi Recorder dropbox app ID.
  37. * @returns {Promise<Object|undefined>}
  38. */
  39. export function getDropboxData(
  40. token: string,
  41. clientId: string
  42. ): Promise<?Object> {
  43. const dropboxAPI = new Dropbox({
  44. accessToken: token,
  45. clientId
  46. });
  47. return Promise.all(
  48. [ dropboxAPI.usersGetCurrentAccount(), dropboxAPI.usersGetSpaceUsage() ]
  49. ).then(([ account, space ]) => {
  50. const { allocation, used } = space;
  51. const { allocated } = allocation;
  52. return {
  53. userName: account.name.display_name,
  54. spaceLeft: Math.floor((allocated - used) / 1048576)// 1MiB=1048576B
  55. };
  56. }, error => {
  57. logger.error(error);
  58. return undefined;
  59. });
  60. }