2026-10-01 11:37:41 +02:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
using PrivaPub.ClientModels;
|
|
|
|
|
using PrivaPub.Domain.Timelines;
|
|
|
|
|
using PrivaPub.Extensions;
|
|
|
|
|
|
|
|
|
|
namespace PrivaPub.Controllers.ClientToServer
|
|
|
|
|
{
|
|
|
|
|
[ApiController,
|
|
|
|
|
Route("clientapi/timeline"),
|
|
|
|
|
Authorize(Policy = Policies.IsUser)]
|
2026-11-10 01:24:43 +01:00
|
|
|
public class TimelineController(
|
|
|
|
|
ITimelineService timelines) : ControllerBase
|
2026-10-01 11:37:41 +02:00
|
|
|
{
|
|
|
|
|
[HttpGet, Route("/clientapi/timeline/home")]
|
|
|
|
|
public async Task<IActionResult> Home([FromQuery] string avatarId, [FromQuery(Name = "max_id")] string maxId, [FromQuery] int limit = 20,
|
|
|
|
|
CancellationToken token = default) =>
|
2026-11-10 01:24:43 +01:00
|
|
|
Answer(await timelines.Home(User.GetUserId(), avatarId, maxId, limit, token));
|
2026-10-01 11:37:41 +02:00
|
|
|
|
|
|
|
|
[HttpGet, Route("/clientapi/notifications")]
|
|
|
|
|
public async Task<IActionResult> Notifications([FromQuery] string avatarId, [FromQuery(Name = "max_id")] string maxId, [FromQuery] int limit = 20,
|
|
|
|
|
CancellationToken token = default) =>
|
2026-11-10 01:24:43 +01:00
|
|
|
Answer(await timelines.Notifications(User.GetUserId(), avatarId, maxId, limit, token));
|
2026-10-01 11:37:41 +02:00
|
|
|
|
|
|
|
|
[HttpPost, Route("/clientapi/notifications/read")]
|
|
|
|
|
public async Task<IActionResult> Read([FromQuery] string avatarId, CancellationToken token) =>
|
2026-11-10 01:24:43 +01:00
|
|
|
Answer(await timelines.MarkNotificationsRead(User.GetUserId(), avatarId, token));
|
2026-10-01 11:37:41 +02:00
|
|
|
|
|
|
|
|
IActionResult Answer(WebResult result) => result.IsValid ? Ok(result.Data) : StatusCode(result.StatusCode, result);
|
|
|
|
|
}
|
|
|
|
|
}
|