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;
|
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;
|
|
|
|
|
2020-06-10 11:09:23 +00:00
|
|
|
namespace Jellyfin.Api.Controllers
|
2020-06-09 16:56:17 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Activity log controller.
|
|
|
|
/// </summary>
|
2020-08-04 14:27:54 +00:00
|
|
|
[Route("System/ActivityLog")]
|
2020-06-09 16:56:17 +00:00
|
|
|
[Authorize(Policy = Policies.RequiresElevation)]
|
|
|
|
public class ActivityLogController : BaseJellyfinApiController
|
|
|
|
{
|
|
|
|
private readonly IActivityManager _activityManager;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="ActivityLogController"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="activityManager">Instance of <see cref="IActivityManager"/> interface.</param>
|
|
|
|
public ActivityLogController(IActivityManager activityManager)
|
|
|
|
{
|
|
|
|
_activityManager = activityManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <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>
|
2020-07-20 20:43:54 +00:00
|
|
|
/// <param name="hasUserId">Optional. Filter log entries if it has user id, or not.</param>
|
2020-06-09 16:56:17 +00:00
|
|
|
/// <response code="200">Activity log returned.</response>
|
|
|
|
/// <returns>A <see cref="QueryResult{ActivityLogEntry}"/> containing the log entries.</returns>
|
2020-06-10 11:09:23 +00:00
|
|
|
[HttpGet("Entries")]
|
2020-06-09 16:56:17 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-10-04 01:14:25 +00:00
|
|
|
public async Task<ActionResult<QueryResult<ActivityLogEntry>>> GetLogEntries(
|
2020-06-09 16:56:17 +00:00
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
[FromQuery] int? limit,
|
2020-07-20 20:43:54 +00:00
|
|
|
[FromQuery] DateTime? minDate,
|
|
|
|
[FromQuery] bool? hasUserId)
|
2020-06-09 16:56:17 +00:00
|
|
|
{
|
2020-10-04 01:14:25 +00:00
|
|
|
return await _activityManager.GetPagedResultAsync(new ActivityLogQuery
|
|
|
|
{
|
2021-05-21 00:48:41 +00:00
|
|
|
Skip = startIndex,
|
2020-10-04 01:14:25 +00:00
|
|
|
Limit = limit,
|
|
|
|
MinDate = minDate,
|
|
|
|
HasUserId = hasUserId
|
|
|
|
}).ConfigureAwait(false);
|
2020-06-09 16:56:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|