mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 19:52:36 +01:00
rename unique uesrname response and schema
This commit is contained in:
parent
5c220b4bdf
commit
cf34ab1674
@ -5729,6 +5729,17 @@
|
|||||||
"ticket"
|
"ticket"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"UniqueUsernameAttemptSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"username"
|
||||||
|
]
|
||||||
|
},
|
||||||
"UserDeleteSchema": {
|
"UserDeleteSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -6011,17 +6022,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"UsernameAttemptUnauthedSchema": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"username": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"username"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"VanityUrlSchema": {
|
"VanityUrlSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -7140,6 +7140,108 @@
|
|||||||
"$ref": "#/components/schemas/BackupCode"
|
"$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": {
|
"UserUpdateResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -8027,7 +8129,7 @@
|
|||||||
"days"
|
"days"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"UsernameAttemptResponse": {
|
"UniqueUsernameAttemptResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"taken": {
|
"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}": {
|
"/users/@me/notes/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@ -9793,11 +10010,7 @@
|
|||||||
},
|
},
|
||||||
"/unique-username/username-suggestions-unauthed/": {
|
"/unique-username/username-suggestions-unauthed/": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"description": "Returns a suggested unique username string based on the current user's username.",
|
||||||
{
|
|
||||||
"bearer": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"400": {
|
"400": {
|
||||||
"description": "",
|
"description": "",
|
||||||
@ -9827,18 +10040,13 @@
|
|||||||
},
|
},
|
||||||
"/unique-username/username-attempt-unauthed/": {
|
"/unique-username/username-attempt-unauthed/": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"description": "Checks whether a unique username is available for the user to claim.",
|
||||||
{
|
|
||||||
"bearer": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Check if a username is available",
|
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/UsernameAttemptUnauthedSchema"
|
"$ref": "#/components/schemas/UniqueUsernameAttemptSchema"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9849,7 +10057,7 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"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 { 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 { Request, Response, Router } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
const router = Router();
|
const router = Router();
|
||||||
@ -7,15 +7,16 @@ const router = Router();
|
|||||||
router.post(
|
router.post(
|
||||||
"/",
|
"/",
|
||||||
route({
|
route({
|
||||||
requestBody: "UsernameAttemptUnauthedSchema",
|
requestBody: "UniqueUsernameAttemptSchema",
|
||||||
responses: {
|
responses: {
|
||||||
200: { body: "UsernameAttemptResponse" },
|
200: { body: "UniqueUsernameAttemptResponse" },
|
||||||
400: { body: "APIErrorResponse" },
|
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) => {
|
async (req: Request, res: Response) => {
|
||||||
const body = req.body as UsernameAttemptUnauthedSchema;
|
const body = req.body as UniqueUsernameAttemptSchema;
|
||||||
const { uniqueUsernames } = Config.get().general;
|
const { uniqueUsernames } = Config.get().general;
|
||||||
if (!uniqueUsernames) {
|
if (!uniqueUsernames) {
|
||||||
throw new HTTPError(
|
throw new HTTPError(
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { route } from "@spacebar/api";
|
import { route } from "@spacebar/api";
|
||||||
|
import { Config } from "@spacebar/util";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
import { Config } from "../../../util";
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
"/",
|
"/",
|
||||||
route({
|
route({
|
||||||
|
description:
|
||||||
|
"Returns a suggested unique username string based on the current user's username.",
|
||||||
query: {
|
query: {
|
||||||
global_name: {
|
global_name: {
|
||||||
type: "string",
|
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 "./TotpDisableSchema";
|
||||||
export * from "./TotpEnableSchema";
|
export * from "./TotpEnableSchema";
|
||||||
export * from "./TotpSchema";
|
export * from "./TotpSchema";
|
||||||
|
export * from "./UniqueUsernameAttemptSchema";
|
||||||
export * from "./UserDeleteSchema";
|
export * from "./UserDeleteSchema";
|
||||||
export * from "./UserGuildSettingsSchema";
|
export * from "./UserGuildSettingsSchema";
|
||||||
export * from "./UserModifySchema";
|
export * from "./UserModifySchema";
|
||||||
export * from "./UserNoteUpdateSchema";
|
export * from "./UserNoteUpdateSchema";
|
||||||
export * from "./UserProfileModifySchema";
|
export * from "./UserProfileModifySchema";
|
||||||
export * from "./UserSettingsSchema";
|
export * from "./UserSettingsSchema";
|
||||||
export * from "./UsernameAttemptUnauthedSchema";
|
|
||||||
export * from "./Validator";
|
export * from "./Validator";
|
||||||
export * from "./VanityUrlSchema";
|
export * from "./VanityUrlSchema";
|
||||||
export * from "./VoiceIdentifySchema";
|
export * from "./VoiceIdentifySchema";
|
||||||
|
@ -60,6 +60,9 @@ export type APIDMChannelArray = DmChannelDTO[];
|
|||||||
|
|
||||||
export type APIBackupCodeArray = BackupCode[];
|
export type APIBackupCodeArray = BackupCode[];
|
||||||
|
|
||||||
|
export type PrivateUserResponse = APIPrivateUser;
|
||||||
|
export type PublicUserResponse = APIPublicUser;
|
||||||
|
|
||||||
export interface UserUpdateResponse extends APIPrivateUser {
|
export interface UserUpdateResponse extends APIPrivateUser {
|
||||||
newToken?: string;
|
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