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

35 lines
1.0 KiB
C#
Raw Normal View History

using PrivaPub.Domain.Statuses;
using PrivaPub.Models.User;
using System.Text.Json.Nodes;
namespace PrivaPub.Federation.Inbox.Handlers
{
// FEP-5624 (PeerTube): the author of a post whose canReply asks it to approve each reply lets one of ours in, which then
// goes to its audience carrying the approval (replyApproval)
public class ReplyApprovalHandler : IActivityHandler
{
readonly IInteractionApprovals _approvals;
public ReplyApprovalHandler(IInteractionApprovals approvals) => _approvals = approvals;
public virtual string Type => "ApproveReply";
protected virtual bool Approves => true;
public async Task Handle(JsonNode activity, ForeignAvatar actor, CancellationToken token) =>
await _approvals.Answered(activity, actor, Approves, token);
}
// and refuses one, which stays ours alone
public class ReplyRejectionHandler : ReplyApprovalHandler
{
public ReplyRejectionHandler(IInteractionApprovals approvals) : base(approvals)
{
}
public override string Type => "RejectReply";
protected override bool Approves => false;
}
}