This commit is contained in:
2025-09-03 14:32:02 -04:00
parent c6e2b6e4d3
commit 03b751dda6
22 changed files with 1429 additions and 150 deletions

View File

@@ -50,14 +50,18 @@ export default class SocketConsoleHandler {
async #onMsg(ev: MessageEvent) {
try {
const parsed = JSON.parse(ev.data) as ConsoleItem;
const zodd = ConsoleItemSchema.safeParse(parsed);
if (!zodd.success) this.destroy();
else if (zodd.data.e == ConsoleEvent.Command) {
const data = await Server.Commands.dispatch(...zodd.data.d.split(' '));
const zodParsed = ConsoleItemSchema.safeParse(parsed);
if (!zodParsed.success) this.destroy();
else if (zodParsed.data.e == ConsoleEvent.Command) {
const data = await Server.Commands.dispatch(...zodParsed.data.d.split(' '));
if (data instanceof Error) throw data;
this.send(ConsoleEvent.Message, chalk.gray(`> ${chalk.yellow(data)}`));
}
else if (zodd.data.e == ConsoleEvent.Close) this.destroy();
else if (zodParsed.data.e == ConsoleEvent.Close) this.destroy();
} catch (err) {
this.#log.e(err);
}

View File

@@ -3,6 +3,7 @@ import {
CompletionMessage,
Message,
MessageKind,
NotificationHandler,
PushNotificationId,
SignalMessageType,
SignalRMessage,
@@ -164,7 +165,7 @@ export class SignalRSocketHandler {
}
}
sendNotification(id: PushNotificationId | string, args?: object) {
sendNotification(id: PushNotificationId | NotificationHandler, args?: object) {
const msg: SignalRMessage = {
type: SignalMessageType.Invocation,
target: "Notification",

View File

@@ -182,4 +182,20 @@ export enum PushNotificationId {
CommunityBoardUpdate = 95,
CommunityBoardAnnouncementUpdate,
InventionModerationStateChanged = 100,
}
}
const notificationHandlers = [
"AccountUpdate",
"SelfAccountUpdate",
"AnnouncementUpdate",
"AnnouncementDelete",
"ChatMessageReceived",
"CommerceSubscriptionUpdate",
"RoomInstanceUpdate",
"PresenceUpdate",
"ModerationQuitGame",
"AppVersionUpdate",
"PlayerProgressionLevelUpdate",
"ReputationUpdate"
] as const;
export type NotificationHandler = typeof notificationHandlers[number];