1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 02:12:40 +01:00

fix poll in msg create schema

This commit is contained in:
Madeline 2024-07-09 15:27:24 +10:00
parent c52d6c49a3
commit 35c9a09ea5
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
4 changed files with 30360 additions and 6003 deletions

View File

@ -734,6 +734,114 @@
}
}
},
"MessageComponent": {
"type": "object",
"properties": {
"type": {
"type": "integer"
},
"style": {
"type": "integer"
},
"label": {
"type": "string"
},
"emoji": {
"$ref": "#/components/schemas/PartialEmoji"
},
"custom_id": {
"type": "string"
},
"sku_id": {
"type": "string"
},
"url": {
"type": "string"
},
"disabled": {
"type": "boolean"
},
"components": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MessageComponent"
}
}
},
"required": [
"components",
"type"
]
},
"PartialEmoji": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"animated": {
"type": "boolean"
}
},
"required": [
"name"
]
},
"PollCreationSchema": {
"type": "object",
"properties": {
"question": {
"$ref": "#/components/schemas/PollMedia"
},
"answers": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PollAnswer"
}
},
"duration": {
"type": "integer"
},
"allow_multiselect": {
"type": "boolean"
},
"layout_type": {
"type": "integer"
}
},
"required": [
"answers",
"question"
]
},
"PollMedia": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"emoji": {
"$ref": "#/components/schemas/PartialEmoji"
}
}
},
"PollAnswer": {
"type": "object",
"properties": {
"answer_id": {
"type": "string"
},
"poll_media": {
"$ref": "#/components/schemas/PollMedia"
}
},
"required": [
"poll_media"
]
},
"ChannelOverride": {
"type": "object",
"properties": {
@ -1193,7 +1301,8 @@
"$ref": "#/components/schemas/Guild"
},
"parent_id": {
"type": "string"
"type": "string",
"nullable": true
},
"parent": {
"$ref": "#/components/schemas/Channel"
@ -1802,6 +1911,10 @@
"type": "integer",
"default": 0
},
"friend_discovery_flags": {
"type": "integer",
"default": 0
},
"friend_source_flags": {
"$ref": "#/components/schemas/FriendSourceFlags"
},
@ -1892,6 +2005,10 @@
"timezone_offset": {
"type": "integer",
"default": 0
},
"view_nsfw_guilds": {
"type": "boolean",
"default": true
}
},
"required": [
@ -1908,6 +2025,7 @@
"disable_games_tab",
"enable_tts_command",
"explicit_content_filter",
"friend_discovery_flags",
"friend_source_flags",
"gateway_connected",
"gif_auto_play",
@ -1926,7 +2044,8 @@
"status",
"stream_notifications_enabled",
"theme",
"timezone_offset"
"timezone_offset",
"view_nsfw_guilds"
]
},
"SecurityKey": {
@ -2240,6 +2359,12 @@
"$ref": "#/components/schemas/MessageComponent"
}
},
"poll": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Poll"
}
},
"id": {
"type": "string"
}
@ -2963,23 +3088,6 @@
"user_ids"
]
},
"PartialEmoji": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"animated": {
"type": "boolean"
}
},
"required": [
"name"
]
},
"MessageType": {
"enum": [
0,
@ -3018,40 +3126,71 @@
],
"type": "number"
},
"MessageComponent": {
"Poll": {
"type": "object",
"properties": {
"type": {
"type": "integer"
"question": {
"$ref": "#/components/schemas/PollMedia"
},
"style": {
"type": "integer"
},
"label": {
"type": "string"
},
"emoji": {
"$ref": "#/components/schemas/PartialEmoji"
},
"custom_id": {
"type": "string"
},
"url": {
"type": "string"
},
"disabled": {
"type": "boolean"
},
"components": {
"answers": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MessageComponent"
"$ref": "#/components/schemas/PollAnswer"
}
},
"expiry": {
"type": "string",
"format": "date-time"
},
"allow_multiselect": {
"type": "boolean"
},
"results": {
"$ref": "#/components/schemas/PollResult"
}
},
"required": [
"allow_multiselect",
"answers",
"expiry",
"question"
]
},
"PollResult": {
"type": "object",
"properties": {
"is_finalized": {
"type": "boolean"
},
"answer_counts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PollAnswerCount"
}
}
},
"required": [
"components",
"type"
"answer_counts",
"is_finalized"
]
},
"PollAnswerCount": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"count": {
"type": "integer"
},
"me_voted": {
"type": "boolean"
}
},
"required": [
"count",
"id",
"me_voted"
]
},
"VoiceState": {
@ -3444,7 +3583,12 @@
},
"components": {
"type": "array",
"items": {}
"items": {
"$ref": "#/components/schemas/MessageComponent"
}
},
"poll": {
"$ref": "#/components/schemas/Poll"
},
"hit": {
"type": "boolean",
@ -3466,6 +3610,7 @@
"mention_roles",
"mentions",
"pinned",
"poll",
"timestamp",
"tts",
"type"
@ -5212,7 +5357,27 @@
},
"components": {
"type": "array",
"items": {}
"items": {
"$ref": "#/components/schemas/MessageComponent"
}
},
"poll": {
"$ref": "#/components/schemas/PollCreationSchema"
},
"enforce_nonce": {
"type": "boolean"
},
"applied_tags": {
"type": "array",
"items": {
"type": "string"
}
},
"thread_name": {
"type": "string"
},
"avatar_url": {
"type": "string"
}
}
},
@ -5338,7 +5503,27 @@
},
"components": {
"type": "array",
"items": {}
"items": {
"$ref": "#/components/schemas/MessageComponent"
}
},
"poll": {
"$ref": "#/components/schemas/PollCreationSchema"
},
"enforce_nonce": {
"type": "boolean"
},
"applied_tags": {
"type": "array",
"items": {
"type": "string"
}
},
"thread_name": {
"type": "string"
},
"avatar_url": {
"type": "string"
}
}
},
@ -5919,6 +6104,9 @@
"explicit_content_filter": {
"type": "integer"
},
"friend_discovery_flags": {
"type": "integer"
},
"friend_source_flags": {
"$ref": "#/components/schemas/FriendSourceFlags"
},
@ -5982,6 +6170,9 @@
},
"timezone_offset": {
"type": "integer"
},
"view_nsfw_guilds": {
"type": "boolean"
}
}
},
@ -7917,6 +8108,23 @@
"user"
]
},
"BulkBanSchema": {
"type": "object",
"properties": {
"user_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"delete_message_seconds": {
"type": "integer"
}
},
"required": [
"user_ids"
]
},
"BulkDeleteSchema": {
"type": "object",
"properties": {
@ -13729,12 +13937,25 @@
},
"/guilds/{guild_id}/bulk-ban/": {
"post": {
"x-permission-required": "BAN_MEMBERS",
"x-permission-required": [
"BAN_MEMBERS",
"MANAGE_GUILD"
],
"security": [
{
"bearer": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BulkBanSchema"
}
}
}
},
"responses": {
"200": {
"description": "",

File diff suppressed because it is too large Load Diff

View File

@ -16,36 +16,36 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import * as Sentry from "@sentry/node";
import { EmbedHandlers } from "@spacebar/api";
import {
Application,
Attachment,
Channel,
Config,
Embed,
EmbedCache,
emitEvent,
Guild,
Message,
MessageCreateEvent,
MessageUpdateEvent,
EVERYONE_MENTION,
getPermission,
getRights,
Guild,
HERE_MENTION,
Message,
MessageCreateEvent,
MessageCreateSchema,
MessageType,
MessageUpdateEvent,
Role,
ROLE_MENTION,
Sticker,
User,
//CHANNEL_MENTION,
USER_MENTION,
ROLE_MENTION,
Role,
EVERYONE_MENTION,
HERE_MENTION,
MessageType,
User,
Application,
Webhook,
Attachment,
Config,
Sticker,
MessageCreateSchema,
EmbedCache,
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { In } from "typeorm";
import { EmbedHandlers } from "@spacebar/api";
import * as Sentry from "@sentry/node";
const allow_empty = false;
// TODO: check webhook, application, system author, stickers
// TODO: embed gifs/videos/images
@ -66,6 +66,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
: undefined;
const message = Message.create({
...opts,
poll: opts.poll ? [opts.poll] : undefined,
sticker_items: stickers,
guild_id: channel.guild_id,
channel_id: opts.channel_id,

View File

@ -56,7 +56,7 @@ export interface MessageCreateSchema {
sticker_ids?: string[];
components?: MessageComponent[];
// TODO: Fix TypeScript errors in src\api\util\handlers\Message.ts once this is enabled
//poll?: PollCreationSchema;
poll?: PollCreationSchema;
enforce_nonce?: boolean; // For Discord compatibility, it's the default behavior here
applied_tags?: string[]; // Not implemented yet, for webhooks in forums
thread_name?: string; // Not implemented yet, for webhooks