diff --git a/webclient/src/store/server/server.interfaces.ts b/webclient/src/store/server/server.interfaces.ts index afcd9c0ec..3e012256a 100644 --- a/webclient/src/store/server/server.interfaces.ts +++ b/webclient/src/store/server/server.interfaces.ts @@ -1,4 +1,4 @@ -import { Log, SortBy, User, UserSortField, WebSocketConnectOptions } from 'types'; +import { LogItem, SortBy, User, UserSortField, WebSocketConnectOptions } from 'types'; export interface ServerConnectParams { host: string; @@ -63,9 +63,9 @@ export interface ServerStateInfo { } export interface ServerStateLogs { - room: Log[]; - game: Log[]; - chat: Log[]; + room: LogItem[]; + game: LogItem[]; + chat: LogItem[]; } export interface ServerStateSortUsersBy extends SortBy { diff --git a/webclient/src/types/index.ts b/webclient/src/types/index.ts index 59153999c..00838a16d 100644 --- a/webclient/src/types/index.ts +++ b/webclient/src/types/index.ts @@ -15,3 +15,4 @@ export * from './languages'; export * from './logs'; export * from './session'; export * from './deckList'; +export * from './moderator'; diff --git a/webclient/src/types/moderator.ts b/webclient/src/types/moderator.ts new file mode 100644 index 000000000..5991ec6c1 --- /dev/null +++ b/webclient/src/types/moderator.ts @@ -0,0 +1,21 @@ +export interface BanHistoryItem { + adminId: string; + adminName: string; + banTime: string; + banLength: string; + banReason: string; + visibleReason: string; +} + +export interface WarnHistoryItem { + userName: string; + adminName: string; + reason: string; + timeOf: string; +} + +export interface WarnListItem { + warning: string; + userName: string; + userClientid: string; +} diff --git a/webclient/src/types/server.ts b/webclient/src/types/server.ts index fa9f41091..305a5a810 100644 --- a/webclient/src/types/server.ts +++ b/webclient/src/types/server.ts @@ -109,7 +109,7 @@ export const KnownHosts = { [KnownHost.TETRARCH]: { port: 443, host: 'mtg.tetrarch.co/servatrice' }, } -export interface Log { +export interface LogItem { message: string; senderId: string; senderIp: string; @@ -121,7 +121,7 @@ export interface Log { } export interface LogGroups { - room: Log[]; - game: Log[]; - chat: Log[]; + room: LogItem[]; + game: LogItem[]; + chat: LogItem[]; } diff --git a/webclient/src/types/user.ts b/webclient/src/types/user.ts index 8a44da6f8..9dab52e0d 100644 --- a/webclient/src/types/user.ts +++ b/webclient/src/types/user.ts @@ -1,22 +1,17 @@ export interface User { accountageSecs: number; name: string; - privlevel: UserAccessLevel; - userLevel: UserPrivLevel; + privlevel: UserPrivLevel; + userLevel: number; realName?: string; country?: string; avatarBmp?: Uint8Array; } -export enum UserAccessLevel { - 'NONE' -} - export enum UserPrivLevel { - 'unknown 1', - 'unknown 2', - 'unknown 3', - 'unknown 4' + NONE = 0, + VIP = 1, + DONOR = 2 } export enum UserSortField { diff --git a/webclient/src/websocket/commands/moderator/getBanHistory.ts b/webclient/src/websocket/commands/moderator/getBanHistory.ts index a75fe51e6..3378f5842 100644 --- a/webclient/src/websocket/commands/moderator/getBanHistory.ts +++ b/webclient/src/websocket/commands/moderator/getBanHistory.ts @@ -13,7 +13,7 @@ export function getBanHistory(userName: string): void { switch (responseCode) { case webClient.protobuf.controller.Response.ResponseCode.RespOk: const { banList } = raw['.Response_BanHistory.ext']; - ModeratorPersistence.banHistory(banList); + ModeratorPersistence.banHistory(userName, banList); return; default: error = 'Failed to get ban history.'; diff --git a/webclient/src/websocket/commands/moderator/getWarnHistory.ts b/webclient/src/websocket/commands/moderator/getWarnHistory.ts index 0a0c4d549..fce008eec 100644 --- a/webclient/src/websocket/commands/moderator/getWarnHistory.ts +++ b/webclient/src/websocket/commands/moderator/getWarnHistory.ts @@ -13,7 +13,7 @@ export function getWarnHistory(userName: string): void { switch (responseCode) { case webClient.protobuf.controller.Response.ResponseCode.RespOk: const { warnList } = raw['.Response_WarnHistory.ext']; - ModeratorPersistence.warnHistory(warnList); + ModeratorPersistence.warnHistory(userName, warnList); return; default: error = 'Failed to get warn history.'; diff --git a/webclient/src/websocket/commands/moderator/warnUser.ts b/webclient/src/websocket/commands/moderator/warnUser.ts index c9c3a2155..bef9ee003 100644 --- a/webclient/src/websocket/commands/moderator/warnUser.ts +++ b/webclient/src/websocket/commands/moderator/warnUser.ts @@ -2,7 +2,7 @@ import webClient from '../../WebClient'; import { ModeratorPersistence } from '../../persistence'; export function warnUser(userName: string, reason: string, clientid?: string, removeMessage?: boolean): void { - const command = webClient.protobuf.controller.Command_BanFromServer.create({ userName, reason, clientid, removeMessage }); + const command = webClient.protobuf.controller.Command_WarnUser.create({ userName, reason, clientid, removeMessage }); const sc = webClient.protobuf.controller.ModeratorCommand.create({ '.Command_WarnUser.ext': command }); webClient.protobuf.sendModeratorCommand(sc, (raw) => { diff --git a/webclient/src/websocket/persistence/ModeratorPresistence.ts b/webclient/src/websocket/persistence/ModeratorPresistence.ts index 3e2e6ea91..4b2f1a6d2 100644 --- a/webclient/src/websocket/persistence/ModeratorPresistence.ts +++ b/webclient/src/websocket/persistence/ModeratorPresistence.ts @@ -1,30 +1,30 @@ import { ServerDispatch } from 'store'; -import { Log } from 'types'; +import { BanHistoryItem, LogItem, WarnHistoryItem, WarnListItem } from 'types'; import NormalizeService from '../utils/NormalizeService'; export class ModeratorPersistence { - static banFromServer(userName: any) { + static banFromServer(userName: string): void { console.log(userName); } - static banHistory(banHistory: any) { - console.log(banHistory); + static banHistory(userName: string, banHistory: BanHistoryItem[]): void { + console.log(userName, banHistory); } - static viewLogs(logs: Log[]) { + static viewLogs(logs: LogItem[]): void { ServerDispatch.viewLogs(NormalizeService.normalizeLogs(logs)); } - static warnHistory(warnList: any) { + static warnHistory(userName: string, warnHistory: WarnHistoryItem[]): void { + console.log(userName, warnHistory); + } + + static warnList(warnList: WarnListItem[]): void { console.log(warnList); } - static warnList(warning: any) { - console.log(warning); - } - - static warnUser(userName: any) { + static warnUser(userName: string): void { console.log(userName); } } diff --git a/webclient/src/websocket/utils/NormalizeService.ts b/webclient/src/websocket/utils/NormalizeService.ts index dcb7a54fb..4d9d37ba6 100644 --- a/webclient/src/websocket/utils/NormalizeService.ts +++ b/webclient/src/websocket/utils/NormalizeService.ts @@ -1,4 +1,4 @@ -import { Game, GametypeMap, Log, LogGroups, Message, Room } from 'types'; +import { Game, GametypeMap, LogItem, LogGroups, Message, Room } from 'types'; export default class NormalizeService { // Flatten room gameTypes into map object @@ -26,7 +26,7 @@ export default class NormalizeService { } // Flatten logs[] into object mapped by targetType (room, game, chat) - static normalizeLogs(logs: Log[]): LogGroups { + static normalizeLogs(logs: LogItem[]): LogGroups { return logs.reduce((obj, log) => { const { targetType } = log; obj[targetType] = obj[targetType] || [];