2020-06-09 16:56:17 +00:00
|
|
|
using System;
|
2020-10-04 01:14:25 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-06-09 16:56:17 +00:00
|
|
|
using Jellyfin.Api.Constants;
|
2020-10-04 01:14:25 +00:00
|
|
|
using Jellyfin.Data.Queries;
|
2023-11-10 16:17:22 +00:00
|
|
|
using MediaBrowser.Common.Api;
|
2020-06-09 16:56:17 +00:00
|
|
|
using MediaBrowser.Model.Activity;
|
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
namespace Jellyfin.Api.Controllers;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Activity log controller.
|
|
|
|
/// </summary>
|
|
|
|
[Route("System/ActivityLog")]
|
|
|
|
[Authorize(Policy = Policies.RequiresElevation)]
|
|
|
|
public class ActivityLogController : BaseJellyfinApiController
|
2020-06-09 16:56:17 +00:00
|
|
|
{
|
2023-01-31 11:18:10 +00:00
|
|
|
private readonly IActivityManager _activityManager;
|
|
|
|
|
2020-06-09 16:56:17 +00:00
|
|
|
/// <summary>
|
2023-01-31 11:18:10 +00:00
|
|
|
/// Initializes a new instance of the <see cref="ActivityLogController"/> class.
|
2020-06-09 16:56:17 +00:00
|
|
|
/// </summary>
|
2023-01-31 11:18:10 +00:00
|
|
|
/// <param name="activityManager">Instance of <see cref="IActivityManager"/> interface.</param>
|
|
|
|
public ActivityLogController(IActivityManager activityManager)
|
2020-06-09 16:56:17 +00:00
|
|
|
{
|
2023-01-31 11:18:10 +00:00
|
|
|
_activityManager = activityManager;
|
|
|
|
}
|
2020-06-09 16:56:17 +00:00
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets activity log entries.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
|
|
|
|
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
|
|
|
/// <param name="minDate">Optional. The minimum date. Format = ISO.</param>
|
|
|
|
/// <param name="hasUserId">Optional. Filter log entries if it has user id, or not.</param>
|
|
|
|
/// <response code="200">Activity log returned.</response>
|
|
|
|
/// <returns>A <see cref="QueryResult{ActivityLogEntry}"/> containing the log entries.</returns>
|
|
|
|
[HttpGet("Entries")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
public async Task<ActionResult<QueryResult<ActivityLogEntry>>> GetLogEntries(
|
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
[FromQuery] int? limit,
|
|
|
|
[FromQuery] DateTime? minDate,
|
|
|
|
[FromQuery] bool? hasUserId)
|
|
|
|
{
|
|
|
|
return await _activityManager.GetPagedResultAsync(new ActivityLogQuery
|
2020-06-09 16:56:17 +00:00
|
|
|
{
|
2023-01-31 11:18:10 +00:00
|
|
|
Skip = startIndex,
|
|
|
|
Limit = limit,
|
|
|
|
MinDate = minDate,
|
|
|
|
HasUserId = hasUserId
|
|
|
|
}).ConfigureAwait(false);
|
2020-06-09 16:56:17 +00:00
|
|
|
}
|
|
|
|
}
|