Fanout writes a TimelineEntry for every persona a post should reach: the author, local followers of a local author, local followers of a remote one, the members of a direct conversation or a circle. Mastodon's home rules apply when it is written: a reply shows only to followers of both sides (or to the one replied to), a reblog only where reblogs are wanted. A mention of a local persona becomes a Mention notification. Inbound posts are now also kept when a persona follows their author. RemotePosts holds what CreateHandler and backfill share: building a Post from a note, and fetching a public parent the first time a reply to it arrives, so its author is known (a reply to an unknown or non-public parent stays out of home timelines). Each fetched ancestor queues a FetchAncestors job for the next one, up to ten deep. /clientapi/timeline/home and /clientapi/notifications (with /notifications/read) page by max_id for the persona's own root only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
39 lines
1.5 KiB
C#
39 lines
1.5 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("clientapi/timeline"),
|
|
Authorize(Policy = Policies.IsUser)]
|
|
public class TimelineController : ControllerBase
|
|
{
|
|
readonly ITimelineService _timelines;
|
|
|
|
public TimelineController(ITimelineService timelines)
|
|
{
|
|
_timelines = timelines;
|
|
}
|
|
|
|
[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) =>
|
|
Answer(await _timelines.Home(User.GetUserId(), avatarId, maxId, limit, token));
|
|
|
|
[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) =>
|
|
Answer(await _timelines.Notifications(User.GetUserId(), avatarId, maxId, limit, token));
|
|
|
|
[HttpPost, Route("/clientapi/notifications/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);
|
|
}
|
|
}
|