Emit USER_SETTINGS_PROTO_UPDATE

This commit is contained in:
Rory& 2025-07-11 13:59:53 +02:00
parent b62fc8aca8
commit 5466de1c02
3 changed files with 37 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -732,6 +732,7 @@ export type EVENT =
| "RELATIONSHIP_ADD"
| "RELATIONSHIP_REMOVE"
| "SESSIONS_REPLACE"
| "USER_SETTINGS_PROTO_UPDATE"
| CUSTOMEVENTS;
export type CUSTOMEVENTS = "INVALIDATED" | "RATELIMIT";