mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 02:12:40 +01:00
rename unique uesrname response and schema
This commit is contained in:
parent
5c220b4bdf
commit
cf34ab1674
@ -5729,6 +5729,17 @@
|
||||
"ticket"
|
||||
]
|
||||
},
|
||||
"UniqueUsernameAttemptSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"username"
|
||||
]
|
||||
},
|
||||
"UserDeleteSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -6011,17 +6022,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"UsernameAttemptUnauthedSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"username"
|
||||
]
|
||||
},
|
||||
"VanityUrlSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -7140,6 +7140,108 @@
|
||||
"$ref": "#/components/schemas/BackupCode"
|
||||
}
|
||||
},
|
||||
"PrivateUserResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"flags": {
|
||||
"type": "integer"
|
||||
},
|
||||
"premium_since": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"avatar": {
|
||||
"type": "string"
|
||||
},
|
||||
"verified": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"global_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"discriminator": {
|
||||
"type": "string"
|
||||
},
|
||||
"public_flags": {
|
||||
"type": "integer"
|
||||
},
|
||||
"accent_color": {
|
||||
"type": "integer"
|
||||
},
|
||||
"banner": {
|
||||
"type": "string"
|
||||
},
|
||||
"bio": {
|
||||
"type": "string"
|
||||
},
|
||||
"bot": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"premium_type": {
|
||||
"type": "integer"
|
||||
},
|
||||
"theme_colors": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"pronouns": {
|
||||
"type": "string"
|
||||
},
|
||||
"mfa_enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"nsfw_allowed": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"premium": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"purchased_flags": {
|
||||
"type": "integer"
|
||||
},
|
||||
"premium_usage_flags": {
|
||||
"type": "integer"
|
||||
},
|
||||
"disabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"bio",
|
||||
"bot",
|
||||
"disabled",
|
||||
"discriminator",
|
||||
"flags",
|
||||
"id",
|
||||
"mfa_enabled",
|
||||
"nsfw_allowed",
|
||||
"premium",
|
||||
"premium_since",
|
||||
"premium_type",
|
||||
"premium_usage_flags",
|
||||
"public_flags",
|
||||
"purchased_flags",
|
||||
"username",
|
||||
"verified"
|
||||
]
|
||||
},
|
||||
"PublicUserResponse": {
|
||||
"$ref": "#/components/schemas/PublicUser"
|
||||
},
|
||||
"UserUpdateResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -8027,7 +8129,7 @@
|
||||
"days"
|
||||
]
|
||||
},
|
||||
"UsernameAttemptResponse": {
|
||||
"UniqueUsernameAttemptResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"taken": {
|
||||
@ -8450,6 +8552,121 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/users/@me/pomelo/": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Claims a unique username for the user. Returns the updated user object on success. Fires a User Update Gateway event.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UniqueUsernameAttemptSchema"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/PrivateUserResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/users/@me/pomelo-suggestions/": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a suggested unique username string based on the current user's username.",
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/users/@me/pomelo-attempt/": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Checks whether a unique username is available for the user to claim.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UniqueUsernameAttemptSchema"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UniqueUsernameAttemptResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/users/@me/notes/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -9793,11 +10010,7 @@
|
||||
},
|
||||
"/unique-username/username-suggestions-unauthed/": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a suggested unique username string based on the current user's username.",
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "",
|
||||
@ -9827,18 +10040,13 @@
|
||||
},
|
||||
"/unique-username/username-attempt-unauthed/": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Check if a username is available",
|
||||
"description": "Checks whether a unique username is available for the user to claim.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UsernameAttemptUnauthedSchema"
|
||||
"$ref": "#/components/schemas/UniqueUsernameAttemptSchema"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9849,7 +10057,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UsernameAttemptResponse"
|
||||
"$ref": "#/components/schemas/UniqueUsernameAttemptResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17013
assets/schemas.json
17013
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import { Config, User, UsernameAttemptUnauthedSchema } from "@spacebar/util";
|
||||
import { Config, UniqueUsernameAttemptSchema, User } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
const router = Router();
|
||||
@ -7,15 +7,16 @@ const router = Router();
|
||||
router.post(
|
||||
"/",
|
||||
route({
|
||||
requestBody: "UsernameAttemptUnauthedSchema",
|
||||
requestBody: "UniqueUsernameAttemptSchema",
|
||||
responses: {
|
||||
200: { body: "UsernameAttemptResponse" },
|
||||
200: { body: "UniqueUsernameAttemptResponse" },
|
||||
400: { body: "APIErrorResponse" },
|
||||
},
|
||||
description: "Check if a username is available",
|
||||
description:
|
||||
"Checks whether a unique username is available for the user to claim.",
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
const body = req.body as UsernameAttemptUnauthedSchema;
|
||||
const body = req.body as UniqueUsernameAttemptSchema;
|
||||
const { uniqueUsernames } = Config.get().general;
|
||||
if (!uniqueUsernames) {
|
||||
throw new HTTPError(
|
||||
|
@ -1,12 +1,14 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import { Config } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { Config } from "../../../util";
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
"/",
|
||||
route({
|
||||
description:
|
||||
"Returns a suggested unique username string based on the current user's username.",
|
||||
query: {
|
||||
global_name: {
|
||||
type: "string",
|
||||
|
3
src/util/schemas/UniqueUsernameAttemptSchema.ts
Normal file
3
src/util/schemas/UniqueUsernameAttemptSchema.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface UniqueUsernameAttemptSchema {
|
||||
username: string;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export interface UsernameAttemptUnauthedSchema {
|
||||
username: string;
|
||||
}
|
@ -66,13 +66,13 @@ export * from "./TemplateModifySchema";
|
||||
export * from "./TotpDisableSchema";
|
||||
export * from "./TotpEnableSchema";
|
||||
export * from "./TotpSchema";
|
||||
export * from "./UniqueUsernameAttemptSchema";
|
||||
export * from "./UserDeleteSchema";
|
||||
export * from "./UserGuildSettingsSchema";
|
||||
export * from "./UserModifySchema";
|
||||
export * from "./UserNoteUpdateSchema";
|
||||
export * from "./UserProfileModifySchema";
|
||||
export * from "./UserSettingsSchema";
|
||||
export * from "./UsernameAttemptUnauthedSchema";
|
||||
export * from "./Validator";
|
||||
export * from "./VanityUrlSchema";
|
||||
export * from "./VoiceIdentifySchema";
|
||||
|
@ -60,6 +60,9 @@ export type APIDMChannelArray = DmChannelDTO[];
|
||||
|
||||
export type APIBackupCodeArray = BackupCode[];
|
||||
|
||||
export type PrivateUserResponse = APIPrivateUser;
|
||||
export type PublicUserResponse = APIPublicUser;
|
||||
|
||||
export interface UserUpdateResponse extends APIPrivateUser {
|
||||
newToken?: string;
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
export interface UniqueUsernameAttemptResponse {
|
||||
taken: boolean;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export interface UsernameAttemptResponse {
|
||||
taken: boolean;
|
||||
}
|
Loading…
Reference in New Issue
Block a user