Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: AVModeration to use typescript #2642

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions modules/xmpp/AVModeration.js → modules/xmpp/AVModeration.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { getLogger } from '@jitsi/logger';
import { $msg } from 'strophe.js';

import { MediaType } from '../../service/RTC/MediaType';
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
import ChatRoom from './ChatRoom';
import XMPP from './xmpp';

const logger = getLogger(__filename);

Expand All @@ -16,7 +17,13 @@ export default class AVModeration {
*
* @param {ChatRoom} room the main room.
*/
constructor(room) {
private _xmpp: XMPP
private _mainRoom: ChatRoom
private _moderationEnabledByType: { audio: boolean; video: boolean; };
private _whitelistAudio: any[];
private _whitelistVideo: any[];

constructor(room: ChatRoom) {
this._xmpp = room.xmpp;

this._mainRoom = room;
Expand Down Expand Up @@ -52,7 +59,7 @@ export default class AVModeration {
/**
* Enables or disables AV Moderation by sending a msg with command to the component.
*/
enable(state, mediaType) {
enable(state: string, mediaType: MediaType) {
if (!this.isSupported() || !this._mainRoom.isModerator()) {
logger.error(`Cannot enable:${state} AV moderation supported:${this.isSupported()},
moderator:${this._mainRoom.isModerator()}`);
Expand Down Expand Up @@ -80,7 +87,7 @@ export default class AVModeration {
/**
* Approves that a participant can unmute by sending a msg with its jid to the component.
*/
approve(mediaType, jid) {
approve(mediaType: MediaType, jid: string) {
if (!this.isSupported() || !this._mainRoom.isModerator()) {
logger.error(`Cannot approve in AV moderation supported:${this.isSupported()},
moderator:${this._mainRoom.isModerator()}`);
Expand All @@ -101,7 +108,7 @@ export default class AVModeration {
/**
* Rejects that a participant can unmute by sending a msg with its jid to the component.
*/
reject(mediaType, jid) {
reject(mediaType: MediaType, jid: string) {
if (!this.isSupported() || !this._mainRoom.isModerator()) {
logger.error(`Cannot reject in AV moderation supported:${this.isSupported()},
moderator:${this._mainRoom.isModerator()}`);
Expand All @@ -125,7 +132,7 @@ export default class AVModeration {
* @param obj the parsed json content of the message to process.
* @private
*/
_onMessage(obj) {
_onMessage(obj: { removed: any; mediaType: any; enabled: any; approved: any; actor: any; whitelists: any; }) {
const { removed, mediaType: media, enabled, approved, actor, whitelists: newWhitelists } = obj;

if (newWhitelists) {
Expand Down Expand Up @@ -159,4 +166,4 @@ export default class AVModeration {
this._xmpp.eventEmitter.emit(XMPPEvents.AV_MODERATION_APPROVED, media);
}
}
}
}