From 0a22fc89bfa4566515d772567f6489b0dbe798a8 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:20:33 -0400 Subject: [PATCH] fix: Remove erroneous call and perform validation --- .../API/Rest/IDiscordRestChannelAPI.cs | 2 -- .../API/CachingDiscordRestChannelAPI.cs | 1 - .../API/Channels/DiscordRestChannelAPI.cs | 14 ++++++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs index b2f1d36db7..9e6aea54d5 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs @@ -107,7 +107,6 @@ Task SetVoiceChannelStatusAsync /// The tags applied to the thread. /// The default sort order of posts. /// The default layout of posts in a forum. - /// The new status of the voice channel. /// The reason to mark the action in the audit log with. /// The cancellation token for this operation. /// A modification result which may or may not have succeeded. @@ -139,7 +138,6 @@ Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ); diff --git a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs index 722be43ed4..08b9629482 100644 --- a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs @@ -117,7 +117,6 @@ public async Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ) diff --git a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs index 971dde588d..33be7ea2cb 100644 --- a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs @@ -89,10 +89,15 @@ public virtual Task SetVoiceChannelStatusAsync CancellationToken ct = default ) { + if (status is { HasValue: true, Value: { Length: > 500 } }) + { + return Task.FromResult(new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters.")); + } + return this.RestHttpClient.PatchAsync ( $"channels/{channelID}/voice-status", - b => b.WithRateLimitContext(this.RateLimitCache), + b => b.WithJson(b => b.Write("status", status, this.JsonOptions)).WithRateLimitContext(this.RateLimitCache), ct: ct ); } @@ -126,7 +131,6 @@ public virtual async Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -173,11 +177,6 @@ public virtual async Task> ModifyChannelAsync return Result.FromError(packImage); } - if (status is { HasValue: true, Value: { Length: > 500 } }) - { - return new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters."); - } - Optional base64EncodedIcon = packImage.Entity!; return await this.RestHttpClient.PatchAsync @@ -219,7 +218,6 @@ public virtual async Task> ModifyChannelAsync json.Write("applied_tags", appliedTags, this.JsonOptions); json.Write("default_sort_order", defaultSortOrder, this.JsonOptions); json.Write("default_forum_layout", defaultForumLayout, this.JsonOptions); - json.Write("status", status, this.JsonOptions); } ) .WithRateLimitContext(this.RateLimitCache),