2020-06-09 12:56:17 -04:00
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
using Jellyfin.Api.Constants;
|
|
|
|
using MediaBrowser.Model.Activity;
|
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2020-06-10 07:09:23 -04:00
|
|
|
namespace Jellyfin.Api.Controllers
|
2020-06-09 12:56:17 -04:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Activity log controller.
|
|
|
|
/// </summary>
|
2020-06-10 07:09:23 -04:00
|
|
|
[Route("/System/ActivityLog")]
|
2020-06-09 12:56:17 -04: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>
|
|
|
|
/// <param name="hasUserId">Optional. Only returns activities that have a user associated.</param>
|
|
|
|
/// <response code="200">Activity log returned.</response>
|
|
|
|
/// <returns>A <see cref="QueryResult{ActivityLogEntry}"/> containing the log entries.</returns>
|
2020-06-10 07:09:23 -04:00
|
|
|
[HttpGet("Entries")]
|
2020-06-09 12:56:17 -04:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
public ActionResult<QueryResult<ActivityLogEntry>> GetLogEntries(
|
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
[FromQuery] int? limit,
|
2020-06-10 07:09:23 -04:00
|
|
|
[FromQuery] DateTime? minDate,
|
2020-06-09 12:56:17 -04:00
|
|
|
bool? hasUserId)
|
|
|
|
{
|
2020-06-10 07:09:23 -04:00
|
|
|
return _activityManager.GetActivityLogEntries(minDate, hasUserId, startIndex, limit);
|
2020-06-09 12:56:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|