diff --git a/assets/openapi.json b/assets/openapi.json index c5e9276..82b3ff3 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -7669,7 +7669,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -7795,53 +7795,20 @@ "with": { "type": "boolean" }, - "containsAll": { - "type": "boolean" - }, - "partition": { - "type": "boolean" - }, - "single": { - "type": "boolean" - }, - "forEachAsync": { - "type": "boolean" - }, - "filterAsync": { - "type": "boolean" - }, "remove": { "type": "boolean" }, - "first": { + "__@iterator@689": { "type": "boolean" }, - "last": { - "type": "boolean" - }, - "distinct": { - "type": "boolean" - }, - "distinctBy": { - "type": "boolean" - }, - "intersect": { - "type": "boolean" - }, - "except": { - "type": "boolean" - }, - "__@iterator@698": { - "type": "boolean" - }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, @@ -19298,6 +19265,42 @@ ] } }, + "/guilds/{guild_id}/force-recount/": { + "post": { + "x-right-required": "MANAGE_GUILDS", + "security": [ + { + "bearer": [] + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIGuild" + } + } + } + } + }, + "parameters": [ + { + "name": "guild_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "guild_id" + } + ], + "tags": [ + "guilds" + ] + } + }, "/guilds/{guild_id}/emojis/": { "get": { "security": [ @@ -23253,6 +23256,74 @@ ] } }, + "/auth/passwordless/start/": { + "post": { + "security": [ + { + "bearer": [] + } + ], + "responses": { + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIErrorOrCaptchaResponse" + } + } + } + } + }, + "tags": [ + "auth" + ] + } + }, + "/auth/passwordless/finish/": { + "post": { + "security": [ + { + "bearer": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebAuthnSSOSchema" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenResponse" + } + } + } + }, + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIErrorResponse" + } + } + } + } + }, + "tags": [ + "auth" + ] + } + }, "/auth/mfa/webauthn/": { "post": { "requestBody": { @@ -23524,6 +23595,50 @@ ] } }, + "/auth/conditional/finish/": { + "post": { + "security": [ + { + "bearer": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebAuthnSSOSchema" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenResponse" + } + } + } + }, + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIErrorResponse" + } + } + } + } + }, + "tags": [ + "auth" + ] + } + }, "/attachments/refresh-urls/": { "post": { "security": [ diff --git a/assets/schemas.json b/assets/schemas.json index e53b7b5..e4a034d 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -40440,7 +40440,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -40566,53 +40566,20 @@ "with": { "type": "boolean" }, - "containsAll": { - "type": "boolean" - }, - "partition": { - "type": "boolean" - }, - "single": { - "type": "boolean" - }, - "forEachAsync": { - "type": "boolean" - }, - "filterAsync": { - "type": "boolean" - }, "remove": { "type": "boolean" }, - "first": { + "__@iterator@689": { "type": "boolean" }, - "last": { - "type": "boolean" - }, - "distinct": { - "type": "boolean" - }, - "distinctBy": { - "type": "boolean" - }, - "intersect": { - "type": "boolean" - }, - "except": { - "type": "boolean" - }, - "__@iterator@698": { - "type": "boolean" - }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, @@ -40666,7 +40633,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -40792,53 +40759,20 @@ "with": { "type": "boolean" }, - "containsAll": { - "type": "boolean" - }, - "partition": { - "type": "boolean" - }, - "single": { - "type": "boolean" - }, - "forEachAsync": { - "type": "boolean" - }, - "filterAsync": { - "type": "boolean" - }, "remove": { "type": "boolean" }, - "first": { + "__@iterator@689": { "type": "boolean" }, - "last": { - "type": "boolean" - }, - "distinct": { - "type": "boolean" - }, - "distinctBy": { - "type": "boolean" - }, - "intersect": { - "type": "boolean" - }, - "except": { - "type": "boolean" - }, - "__@iterator@698": { - "type": "boolean" - }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, @@ -100139,7 +100073,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -100265,53 +100199,20 @@ "with": { "type": "boolean" }, - "containsAll": { - "type": "boolean" - }, - "partition": { - "type": "boolean" - }, - "single": { - "type": "boolean" - }, - "forEachAsync": { - "type": "boolean" - }, - "filterAsync": { - "type": "boolean" - }, "remove": { "type": "boolean" }, - "first": { + "__@iterator@689": { "type": "boolean" }, - "last": { - "type": "boolean" - }, - "distinct": { - "type": "boolean" - }, - "distinctBy": { - "type": "boolean" - }, - "intersect": { - "type": "boolean" - }, - "except": { - "type": "boolean" - }, - "__@iterator@698": { - "type": "boolean" - }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, diff --git a/src/api/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts index 3a97242..54a6539 100644 --- a/src/api/routes/users/@me/settings.ts +++ b/src/api/routes/users/@me/settings.ts @@ -17,9 +17,9 @@ */ import { route } from "@spacebar/api"; -import { User, UserSettings } from "@spacebar/util"; +import { User, UserSettings, emitEvent, Session, PrivateSessionProjection, PresenceUpdateEvent } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import { UserSettingsUpdateSchema, UserSettingsSchema } from "@spacebar/schemas"; +import { UserSettingsUpdateSchema } from "@spacebar/schemas"; const router = Router({ mergeParams: true }); @@ -74,6 +74,28 @@ await user.settings.save(); await user.save(); + if (body.status) { + const [session] = (await Session.find({ + where: { user_id: user.id }, + })) as [Session | undefined]; + if (session) { + session.status = body.status; + + await Promise.all([ + emitEvent({ + event: "PRESENCE_UPDATE", + user_id: user.id, + data: { + user: user, + activities: session.activities, + client_status: session?.client_status, + status: body.status === "invisible" ? "offline" : body.status, + }, + } as PresenceUpdateEvent), + session.save(), + ]); + } + } res.json({ ...user.settings, index: undefined }); },