From 5466de1c02447333f4cdfe09235b7bd08e548729 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 11 Jul 2025 13:59:53 +0200 Subject: Emit USER_SETTINGS_PROTO_UPDATE --- src/api/routes/users/@me/settings-proto/1.ts | 18 ++++++++++++++++++ src/api/routes/users/@me/settings-proto/2.ts | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'src/api') diff --git a/src/api/routes/users/@me/settings-proto/1.ts b/src/api/routes/users/@me/settings-proto/1.ts index 71ff46b9..dcbad884 100644 --- a/src/api/routes/users/@me/settings-proto/1.ts +++ b/src/api/routes/users/@me/settings-proto/1.ts @@ -19,6 +19,7 @@ import { route } from "@spacebar/api"; import { Request, Response, Router } from "express"; import { + emitEvent, OrmUtils, SettingsProtoJsonResponse, SettingsProtoResponse, @@ -192,6 +193,23 @@ async function patchUserSettings( userSettings.userSettings = settings; await userSettings.save(); + await emitEvent({ + event: "USER_SETTINGS_PROTO_UPDATE", + data: { + settings: { + proto: PreloadedUserSettings.toBase64(settings), + type: 1 + }, + json_settings: { + proto: PreloadedUserSettings.toJson(settings), + type: "user_settings" + }, + partial: false, // Unsure how this should behave + } + }); + // This should also send a USER_SETTINGS_UPDATE event, but that isn't sent + // when using the USER_SETTINGS_PROTOS capability, so we ignore it for now. + return { settings: settings, out_of_date: false, diff --git a/src/api/routes/users/@me/settings-proto/2.ts b/src/api/routes/users/@me/settings-proto/2.ts index dbb331f5..1ca34de7 100644 --- a/src/api/routes/users/@me/settings-proto/2.ts +++ b/src/api/routes/users/@me/settings-proto/2.ts @@ -19,6 +19,7 @@ import { route } from "@spacebar/api"; import { Request, Response, Router } from "express"; import { + emitEvent, OrmUtils, SettingsProtoJsonResponse, SettingsProtoResponse, @@ -194,6 +195,23 @@ async function patchUserSettings( userSettings.frecencySettings = settings; await userSettings.save(); + await emitEvent({ + event: "USER_SETTINGS_PROTO_UPDATE", + data: { + settings: { + proto: FrecencyUserSettings.toBase64(settings), + type: 2 + }, + json_settings: { + proto: FrecencyUserSettings.toJson(settings), + type: "frecency_settings" + }, + partial: false, // Unsure how this should behave + } + }); + // This should also send a USER_SETTINGS_UPDATE event, but that isn't sent + // when using the USER_SETTINGS_PROTOS capability, so we ignore it for now. + return { settings: settings, out_of_date: false, -- cgit 1.5.1