Merge pull request #1135 from DEVTomatoCake/feat/new-msg-props
This commit is contained in:
commit
71b07b9ba2
@ -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": "",
|
||||||
|
36007
assets/schemas.json
36007
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -56,6 +56,7 @@ router.post(
|
|||||||
edited_timestamp: null,
|
edited_timestamp: null,
|
||||||
flags: 1,
|
flags: 1,
|
||||||
components: [],
|
components: [],
|
||||||
|
poll: {},
|
||||||
}).status(200);
|
}).status(200);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -162,6 +162,7 @@ router.get(
|
|||||||
edited_timestamp: x.edited_timestamp,
|
edited_timestamp: x.edited_timestamp,
|
||||||
flags: x.flags,
|
flags: x.flags,
|
||||||
components: x.components,
|
components: x.components,
|
||||||
|
poll: x.poll,
|
||||||
hit: true,
|
hit: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -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,
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -218,6 +218,9 @@ export class Message extends BaseClass {
|
|||||||
@Column({ type: "simple-json", nullable: true })
|
@Column({ type: "simple-json", nullable: true })
|
||||||
components?: MessageComponent[];
|
components?: MessageComponent[];
|
||||||
|
|
||||||
|
@Column({ type: "simple-json", nullable: true })
|
||||||
|
poll?: Poll[];
|
||||||
|
|
||||||
toJSON(): Message {
|
toJSON(): Message {
|
||||||
return {
|
return {
|
||||||
...this,
|
...this,
|
||||||
@ -238,6 +241,7 @@ export class Message extends BaseClass {
|
|||||||
activity: this.activity ?? undefined,
|
activity: this.activity ?? undefined,
|
||||||
application: this.application ?? undefined,
|
application: this.application ?? undefined,
|
||||||
components: this.components ?? undefined,
|
components: this.components ?? undefined,
|
||||||
|
poll: this.poll ?? undefined,
|
||||||
content: this.content ?? "",
|
content: this.content ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -249,6 +253,7 @@ export interface MessageComponent {
|
|||||||
label?: string;
|
label?: string;
|
||||||
emoji?: PartialEmoji;
|
emoji?: PartialEmoji;
|
||||||
custom_id?: string;
|
custom_id?: string;
|
||||||
|
sku_id?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
components: MessageComponent[];
|
components: MessageComponent[];
|
||||||
@ -327,3 +332,32 @@ export interface AllowedMentions {
|
|||||||
users?: string[];
|
users?: string[];
|
||||||
replied_user?: boolean;
|
replied_user?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Poll {
|
||||||
|
question: PollMedia;
|
||||||
|
answers: PollAnswer[];
|
||||||
|
expiry: Date;
|
||||||
|
allow_multiselect: boolean;
|
||||||
|
results?: PollResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollMedia {
|
||||||
|
text?: string;
|
||||||
|
emoji?: PartialEmoji;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollAnswer {
|
||||||
|
answer_id?: string;
|
||||||
|
poll_media: PollMedia;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollResult {
|
||||||
|
is_finalized: boolean;
|
||||||
|
answer_counts: PollAnswerCount[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollAnswerCount {
|
||||||
|
id: string;
|
||||||
|
count: number;
|
||||||
|
me_voted: boolean;
|
||||||
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class MessagePollObject1720157926878 implements MigrationInterface {
|
||||||
|
name = "MessagePollObject1720157926878";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` ADD `poll` text NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `poll`");
|
||||||
|
}
|
||||||
|
}
|
13
src/util/migration/mysql/1720157926878-messagePollObject.ts
Normal file
13
src/util/migration/mysql/1720157926878-messagePollObject.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class MessagePollObject1720157926878 implements MigrationInterface {
|
||||||
|
name = "MessagePollObject1720157926878";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` ADD `poll` text NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `poll`");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class MessagePollObject1720157926878 implements MigrationInterface {
|
||||||
|
name = "MessagePollObject1720157926878";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE messages ADD poll text NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE messages DROP COLUMN poll");
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
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 { Embed } from "@spacebar/util";
|
import { Embed, MessageComponent, PollAnswer, PollMedia } from "@spacebar/util";
|
||||||
|
|
||||||
type Attachment = {
|
type Attachment = {
|
||||||
id: string;
|
id: string;
|
||||||
@ -54,6 +54,21 @@ export interface MessageCreateSchema {
|
|||||||
**/
|
**/
|
||||||
attachments?: Attachment[];
|
attachments?: Attachment[];
|
||||||
sticker_ids?: string[];
|
sticker_ids?: string[];
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
components?: MessageComponent[];
|
||||||
components?: any[];
|
// 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
|
||||||
|
applied_tags?: string[]; // Not implemented yet, for webhooks in forums
|
||||||
|
thread_name?: string; // Not implemented yet, for webhooks
|
||||||
|
avatar_url?: string; // Not implemented yet, for webhooks
|
||||||
|
}
|
||||||
|
|
||||||
|
// TypeScript complains once this is used above
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
interface PollCreationSchema {
|
||||||
|
question: PollMedia;
|
||||||
|
answers: PollAnswer[];
|
||||||
|
duration?: number;
|
||||||
|
allow_multiselect?: boolean;
|
||||||
|
layout_type?: number;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,9 @@
|
|||||||
import {
|
import {
|
||||||
Attachment,
|
Attachment,
|
||||||
Embed,
|
Embed,
|
||||||
|
MessageComponent,
|
||||||
MessageType,
|
MessageType,
|
||||||
|
Poll,
|
||||||
PublicUser,
|
PublicUser,
|
||||||
Role,
|
Role,
|
||||||
} from "../../entities";
|
} from "../../entities";
|
||||||
@ -40,7 +42,8 @@ export interface GuildMessagesSearchMessage {
|
|||||||
timestamp: string;
|
timestamp: string;
|
||||||
edited_timestamp: string | null;
|
edited_timestamp: string | null;
|
||||||
flags: number;
|
flags: number;
|
||||||
components: unknown[];
|
components: MessageComponent[];
|
||||||
|
poll: Poll;
|
||||||
hit: true;
|
hit: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user