mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-30 00:51:51 +00:00
Guard embedless messages when checking for poll results, add reply tests
This commit is contained in:
@@ -52,6 +52,45 @@ public class MessageTests(ITestOutputHelper testOutputHelper, TestFixture fixtur
|
||||
}, cancellationToken: TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendMessageReply() {
|
||||
var r = await Assert.HttpSuccess(await Client.ApiHttpClient.PostAsJsonAsync($"channels/{Channel.Id}/messages", new JsonObject() {
|
||||
{ "content", "meow" }
|
||||
}, cancellationToken: TestContext.Current.CancellationToken));
|
||||
var msg = await r.Content.ReadFromJsonAsync<Message>();
|
||||
await Assert.HttpSuccess(await Client.ApiHttpClient.PostAsJsonAsync($"channels/{Channel.Id}/messages", new JsonObject() {
|
||||
{ "content", "meow" }, {
|
||||
"message_reference", new JsonObject() {
|
||||
{ "guild_id", msg.GuildId.Value.ToString() },
|
||||
{ "channel_id", msg.ChannelId.Value.ToString() },
|
||||
{ "message_id", msg.Id.ToString() },
|
||||
}
|
||||
}
|
||||
}, cancellationToken: TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendMessageReplyAllowedMentions() {
|
||||
var r = await Assert.HttpSuccess(await Client.ApiHttpClient.PostAsJsonAsync($"channels/{Channel.Id}/messages", new JsonObject() {
|
||||
{ "content", "meow" }
|
||||
}, cancellationToken: TestContext.Current.CancellationToken));
|
||||
var msg = await r.Content.ReadFromJsonAsync<Message>();
|
||||
await Assert.HttpSuccess(await Client.ApiHttpClient.PostAsJsonAsync($"channels/{Channel.Id}/messages", new JsonObject() {
|
||||
{ "content", "meow" }, {
|
||||
"message_reference", new JsonObject() {
|
||||
{ "guild_id", msg.GuildId.Value.ToString() },
|
||||
{ "channel_id", msg.ChannelId.Value.ToString() },
|
||||
{ "message_id", msg.Id.ToString() },
|
||||
}
|
||||
}, {
|
||||
"allowed_mentions", new JsonObject() {
|
||||
{ "parse", new JsonArray("users", "roles", "everyone") },
|
||||
{ "replied_user", false }
|
||||
}
|
||||
}
|
||||
}, cancellationToken: TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendMessageMultipart() {
|
||||
var content = new MultipartFormDataContent();
|
||||
|
||||
@@ -768,7 +768,7 @@ async function handleMessageMentionsAsync(message: Message) {
|
||||
);
|
||||
}
|
||||
|
||||
if (message.embeds[0].type === EmbedType.poll_result) {
|
||||
if (message.embeds[0]?.type === EmbedType.poll_result) {
|
||||
message.mentions.push(
|
||||
// @ts-expect-error it does not like the .toPublicUser() lol
|
||||
(await User.findOne({ where: { id: message.author_id } }))!.toPublicUser(),
|
||||
|
||||
Reference in New Issue
Block a user