2022-05-03 08:13:36 +03:00
|
|
|
import { User } from './user.model';
|
|
|
|
|
2022-05-04 00:17:05 +03:00
|
|
|
export enum MessageType {
|
2022-05-03 08:13:36 +03:00
|
|
|
CHAT = 'CHAT',
|
|
|
|
PING = 'PING',
|
|
|
|
NAME_CHANGE = 'NAME_CHANGE',
|
2022-08-10 05:56:45 +03:00
|
|
|
COLOR_CHANGE = 'COLOR_CHANGE',
|
2022-05-03 08:13:36 +03:00
|
|
|
PONG = 'PONG',
|
|
|
|
SYSTEM = 'SYSTEM',
|
|
|
|
USER_JOINED = 'USER_JOINED',
|
2023-09-10 20:58:11 +03:00
|
|
|
USER_PARTED = 'USER_PARTED',
|
2022-05-03 08:13:36 +03:00
|
|
|
CHAT_ACTION = 'CHAT_ACTION',
|
|
|
|
FEDIVERSE_ENGAGEMENT_FOLLOW = 'FEDIVERSE_ENGAGEMENT_FOLLOW',
|
|
|
|
FEDIVERSE_ENGAGEMENT_LIKE = 'FEDIVERSE_ENGAGEMENT_LIKE',
|
|
|
|
FEDIVERSE_ENGAGEMENT_REPOST = 'FEDIVERSE_ENGAGEMENT_REPOST',
|
|
|
|
CONNECTED_USER_INFO = 'CONNECTED_USER_INFO',
|
|
|
|
ERROR_USER_DISABLED = 'ERROR_USER_DISABLED',
|
|
|
|
ERROR_NEEDS_REGISTRATION = 'ERROR_NEEDS_REGISTRATION',
|
|
|
|
ERROR_MAX_CONNECTIONS_EXCEEDED = 'ERROR_MAX_CONNECTIONS_EXCEEDED',
|
|
|
|
VISIBILITY_UPDATE = 'VISIBILITY-UPDATE',
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SocketEvent {
|
|
|
|
id: string;
|
|
|
|
timestamp: Date;
|
2022-05-04 00:17:05 +03:00
|
|
|
type: MessageType;
|
2022-05-03 08:13:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ConnectedClientInfoEvent extends SocketEvent {
|
|
|
|
user: User;
|
|
|
|
}
|
2023-03-04 08:54:01 +03:00
|
|
|
export class ChatEvent implements SocketEvent {
|
|
|
|
constructor(message) {
|
|
|
|
this.id = message.id;
|
|
|
|
this.timestamp = message.timestamp;
|
|
|
|
this.type = message.type;
|
|
|
|
this.body = message.body;
|
|
|
|
if (message.user) {
|
|
|
|
this.user = new User(message.user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
timestamp: Date;
|
|
|
|
|
|
|
|
type: MessageType;
|
|
|
|
|
|
|
|
id: string;
|
|
|
|
|
2022-05-03 08:13:36 +03:00
|
|
|
user: User;
|
2023-03-04 08:54:01 +03:00
|
|
|
|
2022-05-03 08:13:36 +03:00
|
|
|
body: string;
|
2022-05-03 23:01:50 +03:00
|
|
|
}
|
2022-05-26 23:52:04 +03:00
|
|
|
|
|
|
|
export interface NameChangeEvent extends SocketEvent {
|
|
|
|
user: User;
|
|
|
|
oldName: string;
|
|
|
|
}
|
2022-09-05 03:58:06 +03:00
|
|
|
|
|
|
|
export interface MessageVisibilityEvent extends SocketEvent {
|
|
|
|
visible: boolean;
|
|
|
|
ids: string[];
|
|
|
|
}
|
2023-02-06 06:58:24 +03:00
|
|
|
|
|
|
|
export interface FediverseEvent extends SocketEvent {
|
|
|
|
title: string;
|
|
|
|
image: string;
|
|
|
|
link: string;
|
|
|
|
body: string;
|
|
|
|
}
|