| | | 1 | | using System; |
| | | 2 | | using System.Threading.Tasks; |
| | | 3 | | using Jellyfin.Api.Constants; |
| | | 4 | | using Jellyfin.Data.Queries; |
| | | 5 | | using MediaBrowser.Common.Api; |
| | | 6 | | using MediaBrowser.Model.Activity; |
| | | 7 | | using MediaBrowser.Model.Querying; |
| | | 8 | | using Microsoft.AspNetCore.Authorization; |
| | | 9 | | using Microsoft.AspNetCore.Http; |
| | | 10 | | using Microsoft.AspNetCore.Mvc; |
| | | 11 | | |
| | | 12 | | namespace Jellyfin.Api.Controllers; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Activity log controller. |
| | | 16 | | /// </summary> |
| | | 17 | | [Route("System/ActivityLog")] |
| | | 18 | | [Authorize(Policy = Policies.RequiresElevation)] |
| | | 19 | | public class ActivityLogController : BaseJellyfinApiController |
| | | 20 | | { |
| | | 21 | | private readonly IActivityManager _activityManager; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Initializes a new instance of the <see cref="ActivityLogController"/> class. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <param name="activityManager">Instance of <see cref="IActivityManager"/> interface.</param> |
| | 1 | 27 | | public ActivityLogController(IActivityManager activityManager) |
| | | 28 | | { |
| | 1 | 29 | | _activityManager = activityManager; |
| | 1 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets activity log entries. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped fr |
| | | 36 | | /// <param name="limit">Optional. The maximum number of records to return.</param> |
| | | 37 | | /// <param name="minDate">Optional. The minimum date. Format = ISO.</param> |
| | | 38 | | /// <param name="hasUserId">Optional. Filter log entries if it has user id, or not.</param> |
| | | 39 | | /// <response code="200">Activity log returned.</response> |
| | | 40 | | /// <returns>A <see cref="QueryResult{ActivityLogEntry}"/> containing the log entries.</returns> |
| | | 41 | | [HttpGet("Entries")] |
| | | 42 | | [ProducesResponseType(StatusCodes.Status200OK)] |
| | | 43 | | public async Task<ActionResult<QueryResult<ActivityLogEntry>>> GetLogEntries( |
| | | 44 | | [FromQuery] int? startIndex, |
| | | 45 | | [FromQuery] int? limit, |
| | | 46 | | [FromQuery] DateTime? minDate, |
| | | 47 | | [FromQuery] bool? hasUserId) |
| | | 48 | | { |
| | | 49 | | return await _activityManager.GetPagedResultAsync(new ActivityLogQuery |
| | | 50 | | { |
| | | 51 | | Skip = startIndex, |
| | | 52 | | Limit = limit, |
| | | 53 | | MinDate = minDate, |
| | | 54 | | HasUserId = hasUserId |
| | | 55 | | }).ConfigureAwait(false); |
| | | 56 | | } |
| | | 57 | | } |