Build / Build (push) Successful in 36s
Every answer of the Mastodon API and the client API now has its JSON shape generated when the server is built, instead of worked out by reflection while it runs; the bytes sent are unchanged. The small answers that were anonymous objects (the instance documents, notification policies, reports, lists, tags, trends, errors and the empty answers) are named types. A type without generated metadata fails at once in development and on the pasture, and in production is logged and still answered. Three lists that were sent as lazy sequences (moderation reports, the published domain blocks and the languages) are now built first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using PrivaPub.Api.Mastodon.Entities;
|
|
using PrivaPub.Api.Mastodon.Infrastructure;
|
|
using PrivaPub.Api.Mastodon.Mappers;
|
|
using PrivaPub.Federation.Actors;
|
|
|
|
namespace PrivaPub.Api.Mastodon.Controllers
|
|
{
|
|
// Mastodon 4.4's OAuth userinfo (OpenID Connect's shape, GET or POST, the `profile` scope): who the token's persona is,
|
|
// for a site that signs in with it. Only what its public account says already; never its login. The authorization
|
|
// server's metadata names it (OAuthSetup).
|
|
public class UserinfoController(
|
|
MastodonMapper mapper,
|
|
ILocalActorService localActors) : MastodonController
|
|
{
|
|
public const string Path = "/oauth/userinfo";
|
|
|
|
|
|
[HttpGet(Path), HttpPost(Path), Scope("profile")]
|
|
public async Task<IActionResult> Show(CancellationToken token)
|
|
{
|
|
var account = await mapper.Local(Me, false, token);
|
|
return Json(new UserInfoEntity
|
|
{
|
|
Iss = localActors.BaseAddress + "/",
|
|
Sub = Me.Uri,
|
|
Name = account.DisplayName,
|
|
PreferredUsername = account.Username,
|
|
Profile = account.Url,
|
|
Picture = account.Avatar
|
|
});
|
|
}
|
|
}
|
|
}
|