Skip to content
This repository was archived by the owner on Jul 21, 2020. It is now read-only.

Commit ab67c12

Browse files
author
Derek Jensen
committed
chore(chat): add moderator to delete message event
1 parent d0c4980 commit ab67c12

File tree

2 files changed

+86
-7
lines changed

2 files changed

+86
-7
lines changed

src/defs/chat.ts

+78-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export interface IMessageTagComponent {
7575
id: number;
7676
}
7777

78-
export type MessagePart = IMessageTextComponent
78+
export type MessagePart =
79+
| IMessageTextComponent
7980
| IMessageEmoticonComponent
8081
| IMessageLinkComponent
8182
| IMessageTagComponent;
@@ -140,7 +141,6 @@ export interface IUserUpdate {
140141
}
141142

142143
export interface IPollEvent {
143-
144144
/**
145145
* The question being asked.
146146
*/
@@ -215,13 +215,68 @@ export interface IDeleteMessage {
215215
* The message Id.
216216
*/
217217
id: string;
218+
/**
219+
* The moderator that performed the action.
220+
*/
221+
moderator: {
222+
/**
223+
* The moderator's Id.
224+
*/
225+
user_id: number;
226+
/**
227+
* The moderator's name.
228+
*/
229+
user_name: string;
230+
/**
231+
* The roles the moderator has.
232+
*/
233+
user_roles: string[];
234+
/**
235+
* The level of the moderator
236+
*/
237+
user_level: number;
238+
};
218239
}
219240

220241
export interface IPurgeMessage {
221242
/**
222243
* The user's Id.
223244
*/
224245
user_id: number;
246+
/**
247+
* The moderator that performed the action.
248+
*/
249+
moderator: {
250+
/**
251+
* The moderator's Id.
252+
*/
253+
user_id: number;
254+
/**
255+
* The moderator's name.
256+
*/
257+
user_name: string;
258+
/**
259+
* The roles the moderator has.
260+
*/
261+
user_roles: string[];
262+
/**
263+
* The level of the moderator
264+
*/
265+
user_level: number;
266+
};
267+
/**
268+
* The cause of the purge
269+
*/
270+
cause: {
271+
/**
272+
* The type of action that was performed to cause the purge.
273+
*/
274+
type: 'ban' | 'timeout' | 'globaltimeout';
275+
/**
276+
* Optional raw length that was passed from the moderator for timeouts.
277+
*/
278+
durationString?: string;
279+
};
225280
}
226281

227282
export interface IUserTimeout {
@@ -244,3 +299,24 @@ export interface IUserTimeout {
244299
*/
245300
duration: number;
246301
}
302+
303+
export interface IClearMessage {
304+
clearer: {
305+
/**
306+
* The moderator's Id.
307+
*/
308+
user_id: number;
309+
/**
310+
* The moderator's name.
311+
*/
312+
user_name: string;
313+
/**
314+
* The roles the moderator has.
315+
*/
316+
user_roles: string[];
317+
/**
318+
* The level of the moderator
319+
*/
320+
user_level: number;
321+
};
322+
}

src/socket/Socket.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as NodeWebSocket from 'ws';
33

44
import {
55
IChatMessage,
6+
IClearMessage,
67
IDeleteMessage,
78
IPollEvent,
89
IPurgeMessage,
@@ -45,9 +46,11 @@ function isNodeWebSocket(socket: any): socket is NodeWebSocket {
4546
}
4647

4748
function isReactNative() {
48-
return (typeof document === 'undefined'
49-
&& typeof navigator !== 'undefined'
50-
&& navigator.product === 'ReactNative');
49+
return (
50+
typeof document === 'undefined' &&
51+
typeof navigator !== 'undefined' &&
52+
navigator.product === 'ReactNative'
53+
);
5154
}
5255

5356
/**
@@ -170,7 +173,7 @@ export class Socket extends EventEmitter {
170173
public on(event: 'authresult', cb: (res: IUserAuthenticated) => any): this;
171174
public on(event: 'packet', cb: (packet: any) => any): this;
172175
public on(event: 'ChatMessage', cb: (message: IChatMessage) => any): this;
173-
public on(event: 'ClearMessages', cb: () => void): this;
176+
public on(event: 'ClearMessages', cb: (clear: IClearMessage) => any): this;
174177
public on(event: 'DeleteMessage', cb: (message: IDeleteMessage) => any): this;
175178
public on(event: 'PollStart', cb: (poll: IPollEvent) => any): this;
176179
public on(event: 'PollEnd', cb: (poll: IPollEvent) => any): this;
@@ -618,7 +621,7 @@ export class Socket extends EventEmitter {
618621
public call(method: 'whisper', args: [string, string], options?: ICallOptions): Promise<any>;
619622
public call(method: 'history', args: [number], options?: ICallOptions): Promise<IChatMessage[]>;
620623
public call(method: 'timeout', args: [string, string], options?: ICallOptions): Promise<string>;
621-
public call(method: 'optOutEvents', args: (string)[], options?: ICallOptions): Promise<void>;
624+
public call(method: 'optOutEvents', args: string[], options?: ICallOptions): Promise<void>;
622625
public call(method: 'ping', args: [any]): Promise<any>;
623626
public call(method: 'vote:start', args: [string, string[], number]): Promise<void>;
624627
public call(method: string, args: (string | number)[], options?: ICallOptions): Promise<any>;

0 commit comments

Comments
 (0)