summary refs log tree commit diff
path: root/src/api/routes/users
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-07-11 13:59:53 +0200
committerRory& <root@rory.gay>2025-09-29 18:38:06 +0200
commit5466de1c02447333f4cdfe09235b7bd08e548729 (patch)
tree1edec1fd89fc501a470bdcc32c47c99d04498b30 /src/api/routes/users
parentMerge in json representation of settings protos (diff)
downloadserver-ts-5466de1c02447333f4cdfe09235b7bd08e548729.tar.xz
Emit USER_SETTINGS_PROTO_UPDATE
Diffstat (limited to 'src/api/routes/users')
-rw-r--r--src/api/routes/users/@me/settings-proto/1.ts18
-rw-r--r--src/api/routes/users/@me/settings-proto/2.ts18
2 files changed, 36 insertions, 0 deletions
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,