diff options
| author | Brian Arnold <connect@brian-arnold.dev> | 2021-03-29 10:10:44 -0400 |
|---|---|---|
| committer | Brian Arnold <connect@brian-arnold.dev> | 2021-03-29 10:10:44 -0400 |
| commit | ca25301e649342ef5598822fdd9ffc6eb2cd5065 (patch) | |
| tree | 7faa5d6544fed25477a53d084008ef7704b233b5 | |
| parent | 998833ea6e4c52f842949029b278008b276e3e6b (diff) | |
Added Required attribute to Text property of MessageCommand.
| -rw-r--r-- | Jellyfin.Api/Controllers/SessionController.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Model/Session/MessageCommand.cs | 4 |
2 files changed, 3 insertions, 8 deletions
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs index 34dfb6ce7..14686222b 100644 --- a/Jellyfin.Api/Controllers/SessionController.cs +++ b/Jellyfin.Api/Controllers/SessionController.cs @@ -323,13 +323,6 @@ namespace Jellyfin.Api.Controllers [FromRoute, Required] string sessionId, [FromBody, Required] MessageCommand command) { - - // Need to check if message.Text is null, since [Required] can't be applied to properties of a deserialized object. - if (string.IsNullOrWhiteSpace(command.Text)) - { - throw new ArgumentNullException("Message Text may not be empty."); - } - var nullCorrectedCommand = new MessageCommand { Header = string.IsNullOrWhiteSpace(command.Header) ? "Message from Server" : command.Header, diff --git a/MediaBrowser.Model/Session/MessageCommand.cs b/MediaBrowser.Model/Session/MessageCommand.cs index 09abfbb3f..0ee3c720e 100644 --- a/MediaBrowser.Model/Session/MessageCommand.cs +++ b/MediaBrowser.Model/Session/MessageCommand.cs @@ -1,12 +1,14 @@ #nullable disable #pragma warning disable CS1591 +using System.ComponentModel.DataAnnotations; + namespace MediaBrowser.Model.Session { public class MessageCommand { public string Header { get; set; } - + [Required(AllowEmptyStrings = false)] public string Text { get; set; } public long? TimeoutMs { get; set; } |
