2022-07-21 05:42:23 +02:00
|
|
|
const HIDE_MESSAGE_ENDPOINT = `/api/chat/messagevisibility`;
|
|
|
|
const BAN_USER_ENDPOINT = `/api/chat/users/setenabled`;
|
|
|
|
|
|
|
|
class ChatModerationService {
|
|
|
|
public static async removeMessage(id: string, accessToken: string): Promise<any> {
|
|
|
|
const url = new URL(HIDE_MESSAGE_ENDPOINT, window.location.toString());
|
|
|
|
url.searchParams.append('accessToken', accessToken);
|
|
|
|
const hideMessageUrl = url.toString();
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
body: JSON.stringify({ idArray: [id] }),
|
|
|
|
};
|
|
|
|
|
|
|
|
await fetch(hideMessageUrl, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async banUser(id: string, accessToken: string): Promise<any> {
|
|
|
|
const url = new URL(BAN_USER_ENDPOINT, window.location.toString());
|
|
|
|
url.searchParams.append('accessToken', accessToken);
|
|
|
|
const hideMessageUrl = url.toString();
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
2023-03-02 02:58:15 +01:00
|
|
|
body: JSON.stringify({ userId: id }),
|
2022-07-21 05:42:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
await fetch(hideMessageUrl, options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ChatModerationService;
|