Each refusal and failure the client API sends now starts with a code no other failure uses, such as "[ERR0030006] That code is not valid.", so a screenshot or a report points at the exact place it came from. Nothing another program reads changes: ActivityPub, the Mastodon API's errors, sign-in tokens and the error kinds decePubClient branches on stay as they were. The house-rules checks move to 1.1.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using PrivaPub.ClientModels;
|
|
using PrivaPub.ClientModels.Social;
|
|
using PrivaPub.Domain.Social;
|
|
using PrivaPub.Extensions;
|
|
using PrivaPub.Resources;
|
|
|
|
namespace PrivaPub.Controllers.ClientToServer
|
|
{
|
|
[ApiController,
|
|
Route(ApiPaths.Social.Prefix),
|
|
Authorize(Policy = Policies.IsUser)]
|
|
public class SocialController(
|
|
IFollowService follows,
|
|
IStringLocalizer<GenericRes> localizer) : ControllerBase
|
|
{
|
|
[HttpPost, Route(ApiPaths.Social.POST_Follow)]
|
|
public async Task<IActionResult> Follow(FollowForm form, CancellationToken token) =>
|
|
!ModelState.IsValid ? Invalid() : Answer(await follows.Follow(User.GetUserId(), form, token));
|
|
|
|
[HttpPost, Route(ApiPaths.Social.POST_Unfollow)]
|
|
public async Task<IActionResult> Unfollow(FollowForm form, CancellationToken token) =>
|
|
!ModelState.IsValid ? Invalid() : Answer(await follows.Unfollow(User.GetUserId(), form, token));
|
|
|
|
[HttpGet, Route(ApiPaths.Social.GET_Following)]
|
|
public async Task<IActionResult> Following([FromQuery] string avatarId, CancellationToken token) =>
|
|
Answer(await follows.Followings(User.GetUserId(), avatarId, token));
|
|
|
|
IActionResult Invalid() => BadRequest(new WebResult().Invalidate(22001.ToCodedError(localizer["Invalid model."])));
|
|
|
|
IActionResult Answer(WebResult result) => result.IsValid ? Ok(result.Data) : StatusCode(result.StatusCode, result);
|
|
}
|
|
}
|