Files
SocialPub/PrivaPub/Federation/Inbox/Handlers/FeaturedHandler.cs
T

26 lines
847 B
C#
Raw Normal View History

2026-10-05 22:48:57 +02:00
using PrivaPub.Federation.Actors;
using PrivaPub.Models.User;
using System.Text.Json.Nodes;
namespace PrivaPub.Federation.Inbox.Handlers
{
// An account pins one of its posts (Add to its `featured` collection) or unpins it (Remove), as Mastodon and Akkoma
// send it; inside a community's announce, the community features a post made in it. Any other target (Smithereen's
// wall, a community's moderators) is not ours to keep.
public class FeaturedHandler : IActivityHandler
{
readonly IFeaturedPosts _featured;
readonly bool _add;
public FeaturedHandler(IFeaturedPosts featured, bool add)
{
_featured = featured;
_add = add;
}
public string Type => _add ? "Add" : "Remove";
public Task Handle(JsonNode activity, ForeignAvatar actor, CancellationToken token) => _featured.Receive(activity, actor, _add, token);
}
}