選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

actions.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // @flow
  2. import { getConferenceState } from '../base/conference';
  3. import { MEDIA_TYPE, type MediaType } from '../base/media/constants';
  4. import {
  5. DISMISS_PENDING_PARTICIPANT,
  6. DISABLE_MODERATION,
  7. ENABLE_MODERATION,
  8. LOCAL_PARTICIPANT_APPROVED,
  9. LOCAL_PARTICIPANT_MODERATION_NOTIFICATION,
  10. PARTICIPANT_APPROVED,
  11. PARTICIPANT_PENDING_AUDIO,
  12. REQUEST_DISABLE_AUDIO_MODERATION,
  13. REQUEST_ENABLE_AUDIO_MODERATION,
  14. REQUEST_DISABLE_VIDEO_MODERATION,
  15. REQUEST_ENABLE_VIDEO_MODERATION
  16. } from './actionTypes';
  17. import { isEnabledFromState } from './functions';
  18. /**
  19. * Action used by moderator to approve audio and video for a participant.
  20. *
  21. * @param {staring} id - The id of the participant to be approved.
  22. * @returns {void}
  23. */
  24. export const approveParticipant = (id: string) => (dispatch: Function, getState: Function) => {
  25. const state = getState();
  26. const { conference } = getConferenceState(state);
  27. if (isEnabledFromState(MEDIA_TYPE.AUDIO, state)) {
  28. conference.avModerationApprove(MEDIA_TYPE.AUDIO, id);
  29. }
  30. if (isEnabledFromState(MEDIA_TYPE.VIDEO, state)) {
  31. conference.avModerationApprove(MEDIA_TYPE.VIDEO, id);
  32. }
  33. };
  34. /**
  35. * Audio or video moderation is disabled.
  36. *
  37. * @param {MediaType} mediaType - The media type that was disabled.
  38. * @param {JitsiParticipant} actor - The actor disabling.
  39. * @returns {{
  40. * type: REQUEST_DISABLE_MODERATED_AUDIO
  41. * }}
  42. */
  43. export const disableModeration = (mediaType: MediaType, actor: Object) => {
  44. return {
  45. type: DISABLE_MODERATION,
  46. mediaType,
  47. actor
  48. };
  49. };
  50. /**
  51. * Hides the notification with the participant that asked to unmute audio.
  52. *
  53. * @param {Object} participant - The participant for which the notification to be hidden.
  54. * @returns {Object}
  55. */
  56. export function dismissPendingAudioParticipant(participant: Object) {
  57. return dismissPendingParticipant(participant.id, MEDIA_TYPE.AUDIO);
  58. }
  59. /**
  60. * Hides the notification with the participant that asked to unmute.
  61. *
  62. * @param {string} id - The participant id for which the notification to be hidden.
  63. * @param {MediaType} mediaType - The media type.
  64. * @returns {Object}
  65. */
  66. export function dismissPendingParticipant(id: string, mediaType: MediaType) {
  67. return {
  68. type: DISMISS_PENDING_PARTICIPANT,
  69. id,
  70. mediaType
  71. };
  72. }
  73. /**
  74. * Audio or video moderation is enabled.
  75. *
  76. * @param {MediaType} mediaType - The media type that was enabled.
  77. * @param {JitsiParticipant} actor - The actor enabling.
  78. * @returns {{
  79. * type: REQUEST_ENABLE_MODERATED_AUDIO
  80. * }}
  81. */
  82. export const enableModeration = (mediaType: MediaType, actor: Object) => {
  83. return {
  84. type: ENABLE_MODERATION,
  85. mediaType,
  86. actor
  87. };
  88. };
  89. /**
  90. * Requests disable of audio moderation.
  91. *
  92. * @returns {{
  93. * type: REQUEST_DISABLE_AUDIO_MODERATION
  94. * }}
  95. */
  96. export const requestDisableAudioModeration = () => {
  97. return {
  98. type: REQUEST_DISABLE_AUDIO_MODERATION
  99. };
  100. };
  101. /**
  102. * Requests disable of video moderation.
  103. *
  104. * @returns {{
  105. * type: REQUEST_DISABLE_VIDEO_MODERATION
  106. * }}
  107. */
  108. export const requestDisableVideoModeration = () => {
  109. return {
  110. type: REQUEST_DISABLE_VIDEO_MODERATION
  111. };
  112. };
  113. /**
  114. * Requests enable of audio moderation.
  115. *
  116. * @returns {{
  117. * type: REQUEST_ENABLE_AUDIO_MODERATION
  118. * }}
  119. */
  120. export const requestEnableAudioModeration = () => {
  121. return {
  122. type: REQUEST_ENABLE_AUDIO_MODERATION
  123. };
  124. };
  125. /**
  126. * Requests enable of video moderation.
  127. *
  128. * @returns {{
  129. * type: REQUEST_ENABLE_VIDEO_MODERATION
  130. * }}
  131. */
  132. export const requestEnableVideoModeration = () => {
  133. return {
  134. type: REQUEST_ENABLE_VIDEO_MODERATION
  135. };
  136. };
  137. /**
  138. * Local participant was approved to be able to unmute audio and video.
  139. *
  140. * @param {MediaType} mediaType - The media type to disable.
  141. * @returns {{
  142. * type: LOCAL_PARTICIPANT_APPROVED
  143. * }}
  144. */
  145. export const localParticipantApproved = (mediaType: MediaType) => {
  146. return {
  147. type: LOCAL_PARTICIPANT_APPROVED,
  148. mediaType
  149. };
  150. };
  151. /**
  152. * Shows notification when A/V moderation is enabled and local participant is still not approved.
  153. *
  154. * @param {MediaType} mediaType - Audio or video media type.
  155. * @returns {Object}
  156. */
  157. export function showModeratedNotification(mediaType: MediaType) {
  158. return {
  159. type: LOCAL_PARTICIPANT_MODERATION_NOTIFICATION,
  160. mediaType
  161. };
  162. }
  163. /**
  164. * Shows a notification with the participant that asked to audio unmute.
  165. *
  166. * @param {Object} participant - The participant for which is the notification.
  167. * @returns {Object}
  168. */
  169. export function participantPendingAudio(participant: Object) {
  170. return {
  171. type: PARTICIPANT_PENDING_AUDIO,
  172. participant
  173. };
  174. }
  175. /**
  176. * A participant was approved to unmute for a mediaType.
  177. *
  178. * @param {string} id - The id of the approved participant.
  179. * @param {MediaType} mediaType - The media type which was approved.
  180. * @returns {{
  181. * type: PARTICIPANT_APPROVED,
  182. * }}
  183. */
  184. export function participantApproved(id: string, mediaType: MediaType) {
  185. return {
  186. type: PARTICIPANT_APPROVED,
  187. id,
  188. mediaType
  189. };
  190. }