1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 10:22:39 +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": { "ChannelOverride": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -1193,7 +1301,8 @@
"$ref": "#/components/schemas/Guild" "$ref": "#/components/schemas/Guild"
}, },
"parent_id": { "parent_id": {
"type": "string" "type": "string",
"nullable": true
}, },
"parent": { "parent": {
"$ref": "#/components/schemas/Channel" "$ref": "#/components/schemas/Channel"
@ -1802,6 +1911,10 @@
"type": "integer", "type": "integer",
"default": 0 "default": 0
}, },
"friend_discovery_flags": {
"type": "integer",
"default": 0
},
"friend_source_flags": { "friend_source_flags": {
"$ref": "#/components/schemas/FriendSourceFlags" "$ref": "#/components/schemas/FriendSourceFlags"
}, },
@ -1892,6 +2005,10 @@
"timezone_offset": { "timezone_offset": {
"type": "integer", "type": "integer",
"default": 0 "default": 0
},
"view_nsfw_guilds": {
"type": "boolean",
"default": true
} }
}, },
"required": [ "required": [
@ -1908,6 +2025,7 @@
"disable_games_tab", "disable_games_tab",
"enable_tts_command", "enable_tts_command",
"explicit_content_filter", "explicit_content_filter",
"friend_discovery_flags",
"friend_source_flags", "friend_source_flags",
"gateway_connected", "gateway_connected",
"gif_auto_play", "gif_auto_play",
@ -1926,7 +2044,8 @@
"status", "status",
"stream_notifications_enabled", "stream_notifications_enabled",
"theme", "theme",
"timezone_offset" "timezone_offset",
"view_nsfw_guilds"
] ]
}, },
"SecurityKey": { "SecurityKey": {
@ -2240,6 +2359,12 @@
"$ref": "#/components/schemas/MessageComponent" "$ref": "#/components/schemas/MessageComponent"
} }
}, },
"poll": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Poll"
}
},
"id": { "id": {
"type": "string" "type": "string"
} }
@ -2963,23 +3088,6 @@
"user_ids" "user_ids"
] ]
}, },
"PartialEmoji": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"animated": {
"type": "boolean"
}
},
"required": [
"name"
]
},
"MessageType": { "MessageType": {
"enum": [ "enum": [
0, 0,
@ -3018,40 +3126,71 @@
], ],
"type": "number" "type": "number"
}, },
"MessageComponent": { "Poll": {
"type": "object", "type": "object",
"properties": { "properties": {
"type": { "question": {
"type": "integer" "$ref": "#/components/schemas/PollMedia"
}, },
"style": { "answers": {
"type": "integer"
},
"label": {
"type": "string"
},
"emoji": {
"$ref": "#/components/schemas/PartialEmoji"
},
"custom_id": {
"type": "string"
},
"url": {
"type": "string"
},
"disabled": {
"type": "boolean"
},
"components": {
"type": "array", "type": "array",
"items": { "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": [ "required": [
"components", "answer_counts",
"type" "is_finalized"
]
},
"PollAnswerCount": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"count": {
"type": "integer"
},
"me_voted": {
"type": "boolean"
}
},
"required": [
"count",
"id",
"me_voted"
] ]
}, },
"VoiceState": { "VoiceState": {
@ -3444,7 +3583,12 @@
}, },
"components": { "components": {
"type": "array", "type": "array",
"items": {} "items": {
"$ref": "#/components/schemas/MessageComponent"
}
},
"poll": {
"$ref": "#/components/schemas/Poll"
}, },
"hit": { "hit": {
"type": "boolean", "type": "boolean",
@ -3466,6 +3610,7 @@
"mention_roles", "mention_roles",
"mentions", "mentions",
"pinned", "pinned",
"poll",
"timestamp", "timestamp",
"tts", "tts",
"type" "type"
@ -5212,7 +5357,27 @@
}, },
"components": { "components": {
"type": "array", "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": { "components": {
"type": "array", "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": { "explicit_content_filter": {
"type": "integer" "type": "integer"
}, },
"friend_discovery_flags": {
"type": "integer"
},
"friend_source_flags": { "friend_source_flags": {
"$ref": "#/components/schemas/FriendSourceFlags" "$ref": "#/components/schemas/FriendSourceFlags"
}, },
@ -5982,6 +6170,9 @@
}, },
"timezone_offset": { "timezone_offset": {
"type": "integer" "type": "integer"
},
"view_nsfw_guilds": {
"type": "boolean"
} }
} }
}, },
@ -7917,6 +8108,23 @@
"user" "user"
] ]
}, },
"BulkBanSchema": {
"type": "object",
"properties": {
"user_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"delete_message_seconds": {
"type": "integer"
}
},
"required": [
"user_ids"
]
},
"BulkDeleteSchema": { "BulkDeleteSchema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -13729,12 +13937,25 @@
}, },
"/guilds/{guild_id}/bulk-ban/": { "/guilds/{guild_id}/bulk-ban/": {
"post": { "post": {
"x-permission-required": "BAN_MEMBERS", "x-permission-required": [
"BAN_MEMBERS",
"MANAGE_GUILD"
],
"security": [ "security": [
{ {
"bearer": [] "bearer": []
} }
], ],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BulkBanSchema"
}
}
}
},
"responses": { "responses": {
"200": { "200": {
"description": "", "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/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as Sentry from "@sentry/node";
import { EmbedHandlers } from "@spacebar/api";
import { import {
Application,
Attachment,
Channel, Channel,
Config,
Embed, Embed,
EmbedCache,
emitEvent, emitEvent,
Guild, EVERYONE_MENTION,
Message,
MessageCreateEvent,
MessageUpdateEvent,
getPermission, getPermission,
getRights, getRights,
Guild,
HERE_MENTION,
Message,
MessageCreateEvent,
MessageCreateSchema,
MessageType,
MessageUpdateEvent,
Role,
ROLE_MENTION,
Sticker,
User,
//CHANNEL_MENTION, //CHANNEL_MENTION,
USER_MENTION, USER_MENTION,
ROLE_MENTION,
Role,
EVERYONE_MENTION,
HERE_MENTION,
MessageType,
User,
Application,
Webhook, Webhook,
Attachment,
Config,
Sticker,
MessageCreateSchema,
EmbedCache,
} from "@spacebar/util"; } from "@spacebar/util";
import { HTTPError } from "lambert-server"; import { HTTPError } from "lambert-server";
import { In } from "typeorm"; import { In } from "typeorm";
import { EmbedHandlers } from "@spacebar/api";
import * as Sentry from "@sentry/node";
const allow_empty = false; const allow_empty = false;
// TODO: check webhook, application, system author, stickers // TODO: check webhook, application, system author, stickers
// TODO: embed gifs/videos/images // TODO: embed gifs/videos/images
@ -66,6 +66,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
: undefined; : undefined;
const message = Message.create({ const message = Message.create({
...opts, ...opts,
poll: opts.poll ? [opts.poll] : undefined,
sticker_items: stickers, sticker_items: stickers,
guild_id: channel.guild_id, guild_id: channel.guild_id,
channel_id: opts.channel_id, channel_id: opts.channel_id,

View File

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