diff --git a/Backend/Remora.Discord.API/API/Objects/Messages/MessageSnapshot.cs b/Backend/Remora.Discord.API/API/Objects/Messages/MessageSnapshot.cs new file mode 100644 index 0000000000..de46afe49a --- /dev/null +++ b/Backend/Remora.Discord.API/API/Objects/Messages/MessageSnapshot.cs @@ -0,0 +1,30 @@ +// +// MessageSnapshot.cs +// +// Author: +// Jarl Gullberg +// +// Copyright (c) Jarl Gullberg +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// + +using JetBrains.Annotations; +using Remora.Discord.API.Abstractions.Objects; + +namespace Remora.Discord.API.Objects; + +/// +[PublicAPI] +public record MessageSnapshot(IPartialMessage Message) : IMessageSnapshot; diff --git a/Backend/Remora.Discord.API/Extensions/ServiceCollectionExtensions.cs b/Backend/Remora.Discord.API/Extensions/ServiceCollectionExtensions.cs index 0ee7df59ad..d6c6094c1f 100644 --- a/Backend/Remora.Discord.API/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/Remora.Discord.API/Extensions/ServiceCollectionExtensions.cs @@ -836,6 +836,7 @@ private static JsonSerializerOptions AddMessageObjectConverters(this JsonSeriali options.AddDataObjectConverter(); options.AddDataObjectConverter(); + options.AddDataObjectConverter(); return options; } diff --git a/Tests/Remora.Discord.API.Tests/API/Objects/Messages/MessageSnapshotTests.cs b/Tests/Remora.Discord.API.Tests/API/Objects/Messages/MessageSnapshotTests.cs new file mode 100644 index 0000000000..653ca01f5e --- /dev/null +++ b/Tests/Remora.Discord.API.Tests/API/Objects/Messages/MessageSnapshotTests.cs @@ -0,0 +1,39 @@ +// +// MessageSnapshotTests.cs +// +// Author: +// Jarl Gullberg +// +// Copyright (c) Jarl Gullberg +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// + +using Remora.Discord.API.Abstractions.Objects; +using Remora.Discord.API.Tests.TestBases; + +namespace Remora.Discord.API.Tests.Objects; + +/// +public class MessageSnapshotTests : ObjectTestBase +{ + /// + /// Initializes a new instance of the class. + /// + /// The test fixture. + public MessageSnapshotTests(JsonBackedTypeTestFixture fixture) + : base(fixture) + { + } +} diff --git a/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_REFERENCE/MESSAGE_REFERENCE.json b/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_REFERENCE/MESSAGE_REFERENCE.json index cb170a498f..c3ce096578 100644 --- a/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_REFERENCE/MESSAGE_REFERENCE.json +++ b/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_REFERENCE/MESSAGE_REFERENCE.json @@ -1,4 +1,5 @@ { + "type": 0, "message_id": "999999999999999999", "channel_id": "999999999999999999", "guild_id": "999999999999999999", diff --git a/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_SNAPSHOT/MESSAGE_SNAPSHOT.json b/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_SNAPSHOT/MESSAGE_SNAPSHOT.json new file mode 100644 index 0000000000..42fcad386d --- /dev/null +++ b/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_SNAPSHOT/MESSAGE_SNAPSHOT.json @@ -0,0 +1,45 @@ +{ + "message": { + "content": "none", + "timestamp": "1970-01-01T00:00:00.000000+00:00", + "edited_timestamp": "1970-01-01T00:00:00.000000+00:00", + "mentions": [ + { + "username": "none", + "discriminator": "9999", + "id": "999999999999999999", + "avatar": "68b329da9893e34099c7d8ad5cb9c940" + } + ], + "mention_roles": [ + "999999999999999999" + ], + "attachments": [ + { + "id": "999999999999999999", + "filename": "file.png", + "size": 0, + "url": "https://www.example.org", + "proxy_url": "https://www.example.org" + } + ], + "embeds": [ + {} + ], + "type": 1, + "flags": 1, + "components": [ + { + "type": 1, + "components": [] + } + ], + "sticker_items": [ + { + "id": "999999999999999999", + "name": "none", + "format_type": 1 + } + ] + } +} \ No newline at end of file diff --git a/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_SNAPSHOT/MESSAGE_SNAPSHOT.optionals.json b/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_SNAPSHOT/MESSAGE_SNAPSHOT.optionals.json new file mode 100644 index 0000000000..42fcad386d --- /dev/null +++ b/Tests/Remora.Discord.Tests/Samples/Objects/MESSAGE_SNAPSHOT/MESSAGE_SNAPSHOT.optionals.json @@ -0,0 +1,45 @@ +{ + "message": { + "content": "none", + "timestamp": "1970-01-01T00:00:00.000000+00:00", + "edited_timestamp": "1970-01-01T00:00:00.000000+00:00", + "mentions": [ + { + "username": "none", + "discriminator": "9999", + "id": "999999999999999999", + "avatar": "68b329da9893e34099c7d8ad5cb9c940" + } + ], + "mention_roles": [ + "999999999999999999" + ], + "attachments": [ + { + "id": "999999999999999999", + "filename": "file.png", + "size": 0, + "url": "https://www.example.org", + "proxy_url": "https://www.example.org" + } + ], + "embeds": [ + {} + ], + "type": 1, + "flags": 1, + "components": [ + { + "type": 1, + "components": [] + } + ], + "sticker_items": [ + { + "id": "999999999999999999", + "name": "none", + "format_type": 1 + } + ] + } +} \ No newline at end of file