Build / Build (push) Successful in 35s
All 384 routes, the Mastodon API, the client API and the frozen federation paths, are read from one class with one nested class per controller. Their values are unchanged, checked one by one against the old literals; decePubClient keeps its own APIs class. Checked against GoToSocial in the pasture: 64 passed, 0 failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using PrivaPub.ClientModels;
|
|
using PrivaPub.Domain.Timelines;
|
|
using PrivaPub.Extensions;
|
|
|
|
namespace PrivaPub.Controllers.ClientToServer
|
|
{
|
|
[ApiController,
|
|
Route(ApiPaths.Timeline.Prefix),
|
|
Authorize(Policy = Policies.IsUser)]
|
|
public class TimelineController(
|
|
ITimelineService timelines) : ControllerBase
|
|
{
|
|
[HttpGet, Route(ApiPaths.Timeline.GET_Home)]
|
|
public async Task<IActionResult> Home([FromQuery] string avatarId, [FromQuery(Name = "max_id")] string maxId, [FromQuery] int limit = 20,
|
|
CancellationToken token = default) =>
|
|
Answer(await timelines.Home(User.GetUserId(), avatarId, maxId, limit, token));
|
|
|
|
[HttpGet, Route(ApiPaths.Timeline.GET_Notifications)]
|
|
public async Task<IActionResult> Notifications([FromQuery] string avatarId, [FromQuery(Name = "max_id")] string maxId, [FromQuery] int limit = 20,
|
|
CancellationToken token = default) =>
|
|
Answer(await timelines.Notifications(User.GetUserId(), avatarId, maxId, limit, token));
|
|
|
|
[HttpPost, Route(ApiPaths.Timeline.POST_Read)]
|
|
public async Task<IActionResult> Read([FromQuery] string avatarId, CancellationToken token) =>
|
|
Answer(await timelines.MarkNotificationsRead(User.GetUserId(), avatarId, token));
|
|
|
|
IActionResult Answer(WebResult result) => result.IsValid ? Ok(result.Data) : StatusCode(result.StatusCode, result);
|
|
}
|
|
}
|