Merge pull request #5631 from BrianCArnold/FixMessageCommand

This commit is contained in:
Claus Vium 2021-04-07 14:36:08 +02:00 committed by GitHub
commit a1718e392b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 11 deletions

View File

@ -313,9 +313,7 @@ namespace Jellyfin.Api.Controllers
/// Issues a command to a client to display a message to the user. /// Issues a command to a client to display a message to the user.
/// </summary> /// </summary>
/// <param name="sessionId">The session id.</param> /// <param name="sessionId">The session id.</param>
/// <param name="text">The message test.</param> /// <param name="command">The <see cref="MessageCommand" /> object containing Header, Message Text, and TimeoutMs.</param>
/// <param name="header">The message header.</param>
/// <param name="timeoutMs">The message timeout. If omitted the user will have to confirm viewing the message.</param>
/// <response code="204">Message sent.</response> /// <response code="204">Message sent.</response>
/// <returns>A <see cref="NoContentResult"/>.</returns> /// <returns>A <see cref="NoContentResult"/>.</returns>
[HttpPost("Sessions/{sessionId}/Message")] [HttpPost("Sessions/{sessionId}/Message")]
@ -323,16 +321,12 @@ namespace Jellyfin.Api.Controllers
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult SendMessageCommand( public ActionResult SendMessageCommand(
[FromRoute, Required] string sessionId, [FromRoute, Required] string sessionId,
[FromQuery, Required] string text, [FromBody, Required] MessageCommand command)
[FromQuery] string? header,
[FromQuery] long? timeoutMs)
{ {
var command = new MessageCommand if (string.IsNullOrWhiteSpace(command.Header))
{ {
Header = string.IsNullOrEmpty(header) ? "Message from Server" : header, command.Header = "Message from Server";
TimeoutMs = timeoutMs, }
Text = text
};
_sessionManager.SendMessageCommand(RequestHelpers.GetSession(_sessionManager, _authContext, Request).Id, sessionId, command, CancellationToken.None); _sessionManager.SendMessageCommand(RequestHelpers.GetSession(_sessionManager, _authContext, Request).Id, sessionId, command, CancellationToken.None);

View File

@ -1,12 +1,15 @@
#nullable disable #nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System.ComponentModel.DataAnnotations;
namespace MediaBrowser.Model.Session namespace MediaBrowser.Model.Session
{ {
public class MessageCommand public class MessageCommand
{ {
public string Header { get; set; } public string Header { get; set; }
[Required(AllowEmptyStrings = false)]
public string Text { get; set; } public string Text { get; set; }
public long? TimeoutMs { get; set; } public long? TimeoutMs { get; set; }