Files
SocialPub/PrivaPub/Api/Mastodon/Controllers/CustomEmojisController.cs
T

22 lines
1.0 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PrivaPub.Api.Mastodon.Entities;
using PrivaPub.Api.Mastodon.Infrastructure;
using PrivaPub.Domain.Content;
namespace PrivaPub.Api.Mastodon.Controllers
{
// Mastodon's list of the server's custom emoji (completion program R7), for clients' pickers: as Mastodon lists them,
// those offered (not disabled) and shown in the picker, by shortcode. Read from LocalEmojis, the copy in memory that every
// change reloads at once (and that is read again when five minutes old), so no request reads the database.
public class CustomEmojisController : MastodonController
{
[HttpGet("/api/v1/custom_emojis"), AllowAnonymous]
public IActionResult List() => Json(LocalEmojis.Current.Values
.Where(e => e.VisibleInPicker)
.OrderBy(e => e.Shortcode, StringComparer.Ordinal)
.Select(e => new CustomEmojiEntity { Shortcode = e.Shortcode, Url = e.Url, StaticUrl = e.StaticUrl, VisibleInPicker = true, Category = e.Category })
.ToList());
}
}