workadventure/front/src/WebRtc/BlackListManager.ts
David Négrier 34cb0ebf39 Users blocking now rely on UUID rather than ID
This way, if a user A blocks another user B, if user B refreshes the browser or leaves and re-enters the room, user B will still be blocked.
As a side effect, this allows us to completely remove the "sockets" property in the SocketManager on the Pusher.
2021-07-07 11:24:51 +02:00

28 lines
783 B
TypeScript

import { Subject } from "rxjs";
class BlackListManager {
private list: string[] = [];
public onBlockStream: Subject<string> = new Subject();
public onUnBlockStream: Subject<string> = new Subject();
isBlackListed(userUuid: string): boolean {
return this.list.find((data) => data === userUuid) !== undefined;
}
blackList(userUuid: string): void {
if (this.isBlackListed(userUuid)) return;
this.list.push(userUuid);
this.onBlockStream.next(userUuid);
}
cancelBlackList(userUuid: string): void {
this.list.splice(
this.list.findIndex((data) => data === userUuid),
1
);
this.onUnBlockStream.next(userUuid);
}
}
export const blackListManager = new BlackListManager();