diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2021-11-21 23:57:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-21 23:57:13 +0100 |
| commit | 39e6658d01e10609c460fb92a7af583e4d04caab (patch) | |
| tree | 18f12cc9d039dc21c7d4cf95a39cfe81eb724d0b /Jellyfin.Api | |
| parent | 8f051c86f7d1f02c9a0d917cf0d0ed52aa88ce6b (diff) | |
| parent | ea355b4262fa0b817930d2bb751c05e6e0ee3022 (diff) | |
Merge pull request #6879 from crobibero/client-log-cleanup
Remove ClientLog endpoints
Diffstat (limited to 'Jellyfin.Api')
| -rw-r--r-- | Jellyfin.Api/Controllers/ClientLogController.cs | 77 | ||||
| -rw-r--r-- | Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs | 30 |
2 files changed, 4 insertions, 103 deletions
diff --git a/Jellyfin.Api/Controllers/ClientLogController.cs b/Jellyfin.Api/Controllers/ClientLogController.cs index 95d07c930..98fd22430 100644 --- a/Jellyfin.Api/Controllers/ClientLogController.cs +++ b/Jellyfin.Api/Controllers/ClientLogController.cs @@ -1,5 +1,4 @@ -using System; -using System.Net.Mime; +using System.Net.Mime; using System.Threading.Tasks; using Jellyfin.Api.Attributes; using Jellyfin.Api.Constants; @@ -7,7 +6,6 @@ using Jellyfin.Api.Helpers; using Jellyfin.Api.Models.ClientLogDtos; using MediaBrowser.Controller.ClientEvent; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Model.ClientLog; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -38,54 +36,6 @@ namespace Jellyfin.Api.Controllers } /// <summary> - /// Post event from client. - /// </summary> - /// <param name="clientLogEventDto">The client log dto.</param> - /// <response code="204">Event logged.</response> - /// <response code="403">Event logging disabled.</response> - /// <returns>Submission status.</returns> - [HttpPost] - [ProducesResponseType(StatusCodes.Status204NoContent)] - [ProducesResponseType(StatusCodes.Status403Forbidden)] - public ActionResult LogEvent([FromBody] ClientLogEventDto clientLogEventDto) - { - if (!_serverConfigurationManager.Configuration.AllowClientLogUpload) - { - return Forbid(); - } - - var (clientName, clientVersion, userId, deviceId) = GetRequestInformation(); - Log(clientLogEventDto, userId, clientName, clientVersion, deviceId); - return NoContent(); - } - - /// <summary> - /// Bulk post events from client. - /// </summary> - /// <param name="clientLogEventDtos">The list of client log dtos.</param> - /// <response code="204">All events logged.</response> - /// <response code="403">Event logging disabled.</response> - /// <returns>Submission status.</returns> - [HttpPost("Bulk")] - [ProducesResponseType(StatusCodes.Status204NoContent)] - [ProducesResponseType(StatusCodes.Status403Forbidden)] - public ActionResult LogEvents([FromBody] ClientLogEventDto[] clientLogEventDtos) - { - if (!_serverConfigurationManager.Configuration.AllowClientLogUpload) - { - return Forbid(); - } - - var (clientName, clientVersion, userId, deviceId) = GetRequestInformation(); - foreach (var dto in clientLogEventDtos) - { - Log(dto, userId, clientName, clientVersion, deviceId); - } - - return NoContent(); - } - - /// <summary> /// Upload a document. /// </summary> /// <response code="200">Document saved.</response> @@ -111,39 +61,20 @@ namespace Jellyfin.Api.Controllers return StatusCode(StatusCodes.Status413PayloadTooLarge, $"Payload must be less than {MaxDocumentSize:N0} bytes"); } - var (clientName, clientVersion, _, _) = GetRequestInformation(); + var (clientName, clientVersion) = GetRequestInformation(); var fileName = await _clientEventLogger.WriteDocumentAsync(clientName, clientVersion, Request.Body) .ConfigureAwait(false); return Ok(new ClientLogDocumentResponseDto(fileName)); } - private void Log( - ClientLogEventDto dto, - Guid userId, - string clientName, - string clientVersion, - string deviceId) - { - _clientEventLogger.Log(new ClientLogEvent( - dto.Timestamp, - dto.Level, - userId, - clientName, - clientVersion, - deviceId, - dto.Message)); - } - - private (string ClientName, string ClientVersion, Guid UserId, string DeviceId) GetRequestInformation() + private (string ClientName, string ClientVersion) GetRequestInformation() { var clientName = ClaimHelpers.GetClient(HttpContext.User) ?? "unknown-client"; var clientVersion = ClaimHelpers.GetIsApiKey(HttpContext.User) ? "apikey" : ClaimHelpers.GetVersion(HttpContext.User) ?? "unknown-version"; - var userId = ClaimHelpers.GetUserId(HttpContext.User) ?? Guid.Empty; - var deviceId = ClaimHelpers.GetDeviceId(HttpContext.User) ?? "unknown-device-id"; - return (clientName, clientVersion, userId, deviceId); + return (clientName, clientVersion); } } } diff --git a/Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs b/Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs deleted file mode 100644 index 9bf9be0a4..000000000 --- a/Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Logging; - -namespace Jellyfin.Api.Models.ClientLogDtos -{ - /// <summary> - /// The client log dto. - /// </summary> - public class ClientLogEventDto - { - /// <summary> - /// Gets or sets the event timestamp. - /// </summary> - [Required] - public DateTime Timestamp { get; set; } - - /// <summary> - /// Gets or sets the log level. - /// </summary> - [Required] - public LogLevel Level { get; set; } - - /// <summary> - /// Gets or sets the log message. - /// </summary> - [Required] - public string Message { get; set; } = string.Empty; - } -} |
