mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-05 10:22:31 +01:00
Merge branch 'master' into feat/webhooks-3
This commit is contained in:
commit
4ca79adcae
@ -635,14 +635,51 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"MessageComponent": {
|
||||
"ActionRowComponent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "integer"
|
||||
"$ref": "#/components/schemas/MessageComponentType.ActionRow"
|
||||
},
|
||||
"components": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ButtonComponent"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/SelectMenuComponent"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/StringSelectMenuComponent"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/TextInputComponent"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"components",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"MessageComponentType.ActionRow": {
|
||||
"type": "number",
|
||||
"enum": [
|
||||
1
|
||||
]
|
||||
},
|
||||
"ButtonComponent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"$ref": "#/components/schemas/MessageComponentType.Button"
|
||||
},
|
||||
"style": {
|
||||
"type": "integer"
|
||||
"$ref": "#/components/schemas/ButtonStyle"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
@ -661,19 +698,30 @@
|
||||
},
|
||||
"disabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"components": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MessageComponent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"components",
|
||||
"style",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"MessageComponentType.Button": {
|
||||
"type": "number",
|
||||
"enum": [
|
||||
2
|
||||
]
|
||||
},
|
||||
"ButtonStyle": {
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6
|
||||
],
|
||||
"type": "number"
|
||||
},
|
||||
"PartialEmoji": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -691,6 +739,199 @@
|
||||
"name"
|
||||
]
|
||||
},
|
||||
"SelectMenuComponent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
3,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"type": "number"
|
||||
},
|
||||
"custom_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"channel_types": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string"
|
||||
},
|
||||
"default_values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/SelectMenuDefaultOption"
|
||||
}
|
||||
},
|
||||
"min_values": {
|
||||
"type": "integer"
|
||||
},
|
||||
"max_values": {
|
||||
"type": "integer"
|
||||
},
|
||||
"disabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"custom_id",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SelectMenuDefaultOption": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"channel",
|
||||
"role",
|
||||
"user"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"StringSelectMenuComponent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"$ref": "#/components/schemas/MessageComponentType.StringSelect"
|
||||
},
|
||||
"options": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/SelectMenuOption"
|
||||
}
|
||||
},
|
||||
"custom_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"channel_types": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string"
|
||||
},
|
||||
"default_values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/SelectMenuDefaultOption"
|
||||
}
|
||||
},
|
||||
"min_values": {
|
||||
"type": "integer"
|
||||
},
|
||||
"max_values": {
|
||||
"type": "integer"
|
||||
},
|
||||
"disabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"custom_id",
|
||||
"options",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"MessageComponentType.StringSelect": {
|
||||
"type": "number",
|
||||
"enum": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"SelectMenuOption": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"emoji": {
|
||||
"$ref": "#/components/schemas/PartialEmoji"
|
||||
},
|
||||
"default": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"label",
|
||||
"value"
|
||||
]
|
||||
},
|
||||
"TextInputComponent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"$ref": "#/components/schemas/MessageComponentType.TextInput"
|
||||
},
|
||||
"custom_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"style": {
|
||||
"$ref": "#/components/schemas/TextInputStyle"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"min_length": {
|
||||
"type": "integer"
|
||||
},
|
||||
"max_length": {
|
||||
"type": "integer"
|
||||
},
|
||||
"required": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"custom_id",
|
||||
"label",
|
||||
"style",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"MessageComponentType.TextInput": {
|
||||
"type": "number",
|
||||
"enum": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"TextInputStyle": {
|
||||
"enum": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "number"
|
||||
},
|
||||
"PollCreationSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -2263,7 +2504,7 @@
|
||||
"components": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MessageComponent"
|
||||
"$ref": "#/components/schemas/ActionRowComponent"
|
||||
}
|
||||
},
|
||||
"poll": {
|
||||
@ -3504,7 +3745,7 @@
|
||||
"components": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MessageComponent"
|
||||
"$ref": "#/components/schemas/ActionRowComponent"
|
||||
}
|
||||
},
|
||||
"poll": {
|
||||
@ -4146,12 +4387,17 @@
|
||||
"type": "integer",
|
||||
"default": 65535
|
||||
},
|
||||
"maxBulkBanUsers": {
|
||||
"type": "integer",
|
||||
"default": 200
|
||||
},
|
||||
"maxChannelsInCategory": {
|
||||
"type": "integer",
|
||||
"default": 65535
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"maxBulkBanUsers",
|
||||
"maxChannels",
|
||||
"maxChannelsInCategory",
|
||||
"maxEmojis",
|
||||
@ -5684,7 +5930,7 @@
|
||||
"components": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MessageComponent"
|
||||
"$ref": "#/components/schemas/ActionRowComponent"
|
||||
}
|
||||
},
|
||||
"poll": {
|
||||
@ -5829,7 +6075,7 @@
|
||||
"components": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MessageComponent"
|
||||
"$ref": "#/components/schemas/ActionRowComponent"
|
||||
}
|
||||
},
|
||||
"poll": {
|
||||
|
39748
assets/schemas.json
39748
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -130,19 +130,25 @@ router.get(
|
||||
query.take = Math.floor(limit / 2);
|
||||
if (query.take != 0) {
|
||||
const [right, left] = await Promise.all([
|
||||
Message.find({ ...query, where: { id: LessThan(around) } }),
|
||||
Message.find({
|
||||
...query,
|
||||
where: { id: MoreThanOrEqual(around) },
|
||||
where: { channel_id, id: LessThan(around) },
|
||||
}),
|
||||
Message.find({
|
||||
...query,
|
||||
where: { channel_id, id: MoreThanOrEqual(around) },
|
||||
order: { timestamp: "ASC" },
|
||||
}),
|
||||
]);
|
||||
left.push(...right);
|
||||
messages = left;
|
||||
messages = left.sort(
|
||||
(a, b) => a.timestamp.getTime() - b.timestamp.getTime(),
|
||||
);
|
||||
} else {
|
||||
query.take = 1;
|
||||
const message = await Message.findOne({
|
||||
...query,
|
||||
where: { id: around },
|
||||
where: { channel_id, id: around },
|
||||
});
|
||||
messages = message ? [message] : [];
|
||||
}
|
||||
@ -151,6 +157,7 @@ router.get(
|
||||
if (BigInt(after) > BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
query.where.id = MoreThan(after);
|
||||
query.order = { timestamp: "ASC" };
|
||||
} else if (before) {
|
||||
if (BigInt(before) > BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
|
@ -27,6 +27,7 @@ import {
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { Config } from "@spacebar/util";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
@ -52,7 +53,8 @@ router.post(
|
||||
|
||||
const userIds: Array<string> = req.body.user_ids;
|
||||
if (!userIds) throw new HTTPError("The user_ids array is missing", 400);
|
||||
if (userIds.length > 200)
|
||||
|
||||
if (userIds.length > Config.get().limits.guild.maxBulkBanUsers)
|
||||
throw new HTTPError(
|
||||
"The user_ids array must be between 1 and 200 in length",
|
||||
400,
|
||||
|
@ -120,7 +120,7 @@ router.patch(
|
||||
if (!body.password)
|
||||
throw FieldErrors({
|
||||
password: {
|
||||
message: req.t("auth:register.INVALID_PASSWORD"),
|
||||
message: req.t("auth:login.INVALID_PASSWORD"),
|
||||
code: "INVALID_PASSWORD",
|
||||
},
|
||||
});
|
||||
@ -160,6 +160,15 @@ router.patch(
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (!body.password) {
|
||||
throw FieldErrors({
|
||||
password: {
|
||||
message: req.t("auth:login.INVALID_PASSWORD"),
|
||||
code: "INVALID_PASSWORD",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (body.discriminator) {
|
||||
|
@ -21,5 +21,6 @@ export class GuildLimits {
|
||||
maxEmojis: number = 2000;
|
||||
maxMembers: number = 25000000;
|
||||
maxChannels: number = 65535;
|
||||
maxBulkBanUsers: number = 200;
|
||||
maxChannelsInCategory: number = 65535;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ export class Message extends BaseClass {
|
||||
};
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
components?: MessageComponent[];
|
||||
components?: ActionRowComponent[];
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
poll?: Poll;
|
||||
@ -259,21 +259,100 @@ export class Message extends BaseClass {
|
||||
}
|
||||
|
||||
export interface MessageComponent {
|
||||
type: number;
|
||||
style?: number;
|
||||
type: MessageComponentType;
|
||||
}
|
||||
|
||||
export interface ActionRowComponent extends MessageComponent {
|
||||
type: MessageComponentType.ActionRow;
|
||||
components: (
|
||||
| ButtonComponent
|
||||
| StringSelectMenuComponent
|
||||
| SelectMenuComponent
|
||||
| TextInputComponent
|
||||
)[];
|
||||
}
|
||||
|
||||
export interface ButtonComponent extends MessageComponent {
|
||||
type: MessageComponentType.Button;
|
||||
style: ButtonStyle;
|
||||
label?: string;
|
||||
emoji?: PartialEmoji;
|
||||
custom_id?: string;
|
||||
sku_id?: string;
|
||||
url?: string;
|
||||
disabled?: boolean;
|
||||
components: MessageComponent[];
|
||||
}
|
||||
|
||||
export enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary = 2,
|
||||
Success = 3,
|
||||
Danger = 4,
|
||||
Link = 5,
|
||||
Premium = 6,
|
||||
}
|
||||
|
||||
export interface SelectMenuComponent extends MessageComponent {
|
||||
type:
|
||||
| MessageComponentType.StringSelect
|
||||
| MessageComponentType.UserSelect
|
||||
| MessageComponentType.RoleSelect
|
||||
| MessageComponentType.MentionableSelect
|
||||
| MessageComponentType.ChannelSelect;
|
||||
custom_id: string;
|
||||
channel_types?: number[];
|
||||
placeholder?: string;
|
||||
default_values?: SelectMenuDefaultOption[]; // only for non-string selects
|
||||
min_values?: number;
|
||||
max_values?: number;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export interface SelectMenuOption {
|
||||
label: string;
|
||||
value: string;
|
||||
description?: string;
|
||||
emoji?: PartialEmoji;
|
||||
default?: boolean;
|
||||
}
|
||||
|
||||
export interface SelectMenuDefaultOption {
|
||||
id: string;
|
||||
type: "user" | "role" | "channel";
|
||||
}
|
||||
|
||||
export interface StringSelectMenuComponent extends SelectMenuComponent {
|
||||
type: MessageComponentType.StringSelect;
|
||||
options: SelectMenuOption[];
|
||||
}
|
||||
|
||||
export interface TextInputComponent extends MessageComponent {
|
||||
type: MessageComponentType.TextInput;
|
||||
custom_id: string;
|
||||
style: TextInputStyle;
|
||||
label: string;
|
||||
min_length?: number;
|
||||
max_length?: number;
|
||||
required?: boolean;
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export enum TextInputStyle {
|
||||
Short = 1,
|
||||
Paragraph = 2,
|
||||
}
|
||||
|
||||
export enum MessageComponentType {
|
||||
Script = 0, // self command script
|
||||
ActionRow = 1,
|
||||
Button = 2,
|
||||
StringSelect = 3,
|
||||
TextInput = 4,
|
||||
UserSelect = 5,
|
||||
RoleSelect = 6,
|
||||
MentionableSelect = 7,
|
||||
ChannelSelect = 8,
|
||||
}
|
||||
|
||||
export interface Embed {
|
||||
|
@ -16,7 +16,12 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Embed, MessageComponent, PollAnswer, PollMedia } from "@spacebar/util";
|
||||
import {
|
||||
ActionRowComponent,
|
||||
Embed,
|
||||
PollAnswer,
|
||||
PollMedia,
|
||||
} from "@spacebar/util";
|
||||
|
||||
export type MessageCreateAttachment = {
|
||||
id: string;
|
||||
@ -54,7 +59,7 @@ export interface MessageCreateSchema {
|
||||
**/
|
||||
attachments?: MessageCreateAttachment[];
|
||||
sticker_ids?: string[];
|
||||
components?: MessageComponent[];
|
||||
components?: ActionRowComponent[];
|
||||
// TODO: Fix TypeScript errors in src\api\util\handlers\Message.ts once this is enabled
|
||||
poll?: PollCreationSchema;
|
||||
enforce_nonce?: boolean; // For Discord compatibility, it's the default behavior here
|
||||
|
@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ActionRowComponent,
|
||||
Attachment,
|
||||
Embed,
|
||||
MessageComponent,
|
||||
MessageType,
|
||||
Poll,
|
||||
PublicUser,
|
||||
@ -42,7 +42,7 @@ export interface GuildMessagesSearchMessage {
|
||||
timestamp: string;
|
||||
edited_timestamp: string | null;
|
||||
flags: number;
|
||||
components: MessageComponent[];
|
||||
components: ActionRowComponent[];
|
||||
poll: Poll;
|
||||
hit: true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user