2022-05-03 07:13:36 +02:00
|
|
|
import { User } from './user.model';
|
|
|
|
|
2022-05-03 23:17:05 +02:00
|
|
|
export enum MessageType {
|
2022-05-03 07:13:36 +02:00
|
|
|
CHAT = 'CHAT',
|
|
|
|
PING = 'PING',
|
|
|
|
NAME_CHANGE = 'NAME_CHANGE',
|
2022-08-10 04:56:45 +02:00
|
|
|
COLOR_CHANGE = 'COLOR_CHANGE',
|
2022-05-03 07:13:36 +02:00
|
|
|
PONG = 'PONG',
|
|
|
|
SYSTEM = 'SYSTEM',
|
|
|
|
USER_JOINED = 'USER_JOINED',
|
2023-09-10 19:58:11 +02:00
|
|
|
USER_PARTED = 'USER_PARTED',
|
2022-05-03 07:13:36 +02: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-03 23:17:05 +02:00
|
|
|
type: MessageType;
|
2022-05-03 07:13:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ConnectedClientInfoEvent extends SocketEvent {
|
|
|
|
user: User;
|
|
|
|
}
|
2023-03-04 06:54:01 +01: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 07:13:36 +02:00
|
|
|
user: User;
|
2023-03-04 06:54:01 +01:00
|
|
|
|
2022-05-03 07:13:36 +02:00
|
|
|
body: string;
|
2022-05-03 22:01:50 +02:00
|
|
|
}
|
2022-05-26 22:52:04 +02:00
|
|
|
|
|
|
|
export interface NameChangeEvent extends SocketEvent {
|
|
|
|
user: User;
|
|
|
|
oldName: string;
|
|
|
|
}
|
2022-09-05 02:58:06 +02:00
|
|
|
|
|
|
|
export interface MessageVisibilityEvent extends SocketEvent {
|
|
|
|
visible: boolean;
|
|
|
|
ids: string[];
|
|
|
|
}
|
2023-02-06 04:58:24 +01:00
|
|
|
|
|
|
|
export interface FediverseEvent extends SocketEvent {
|
|
|
|
title: string;
|
|
|
|
image: string;
|
|
|
|
link: string;
|
|
|
|
body: string;
|
|
|
|
}
|