mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.0 KiB
56 lines
2.0 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Squidex.Areas.Api.Controllers.History.Models;
|
|
using Squidex.Domain.Apps.Entities.History.Repositories;
|
|
using Squidex.Infrastructure.Commands;
|
|
using Squidex.Pipeline;
|
|
using Squidex.Shared;
|
|
|
|
namespace Squidex.Areas.Api.Controllers.History
|
|
{
|
|
/// <summary>
|
|
/// Readonly API to get an event stream.
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = nameof(History))]
|
|
public sealed class HistoryController : ApiController
|
|
{
|
|
private readonly IHistoryEventRepository historyEventRepository;
|
|
|
|
public HistoryController(ICommandBus commandBus, IHistoryEventRepository historyEventRepository)
|
|
: base(commandBus)
|
|
{
|
|
this.historyEventRepository = historyEventRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the events from the history
|
|
/// </summary>
|
|
/// <param name="app">The name of the app.</param>
|
|
/// <param name="channel">The name of the channel.</param>
|
|
/// <returns>
|
|
/// 200 => Events returned.
|
|
/// 404 => App not found.
|
|
/// </returns>
|
|
[HttpGet]
|
|
[Route("apps/{app}/history/")]
|
|
[ProducesResponseType(typeof(HistoryEventDto), 200)]
|
|
[ApiPermission(Permissions.AppCommon)]
|
|
[ApiCosts(0.1)]
|
|
public async Task<IActionResult> GetHistory(string app, string channel)
|
|
{
|
|
var entities = await historyEventRepository.QueryByChannelAsync(AppId, channel, 100);
|
|
|
|
var response = entities.Select(HistoryEventDto.FromHistoryEvent).ToList();
|
|
|
|
return Ok(response);
|
|
}
|
|
}
|
|
}
|
|
|