[backend/masto-client] Add custom emoji endpoints (ISH-104)
This commit is contained in:
parent
4805aef7bf
commit
0c70a23770
1 changed files with 21 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
using System.Net.Mime;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Attributes;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Schemas;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
||||
using Iceshrimp.Backend.Core.Configuration;
|
||||
using Iceshrimp.Backend.Core.Database;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
|
@ -18,6 +19,7 @@ namespace Iceshrimp.Backend.Controllers.Mastodon;
|
|||
public class InstanceController(DatabaseContext db) : ControllerBase
|
||||
{
|
||||
[HttpGet("/api/v1/instance")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(InstanceInfoV1Response))]
|
||||
public async Task<IActionResult> GetInstanceInfoV1([FromServices] IOptionsSnapshot<Config> config)
|
||||
{
|
||||
var userCount =
|
||||
|
@ -35,6 +37,7 @@ public class InstanceController(DatabaseContext db) : ControllerBase
|
|||
}
|
||||
|
||||
[HttpGet("/api/v2/instance")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(InstanceInfoV2Response))]
|
||||
public async Task<IActionResult> GetInstanceInfoV2([FromServices] IOptionsSnapshot<Config> config)
|
||||
{
|
||||
var cutoff = DateTime.UtcNow - TimeSpan.FromDays(30);
|
||||
|
@ -50,4 +53,22 @@ public class InstanceController(DatabaseContext db) : ControllerBase
|
|||
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
[HttpGet("/api/v1/custom_emojis")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmojiEntity>))]
|
||||
public async Task<IActionResult> GetCustomEmojis()
|
||||
{
|
||||
var res = await db.Emojis.Where(p => p.Host == null)
|
||||
.Select(p => new EmojiEntity
|
||||
{
|
||||
Id = p.Id,
|
||||
Shortcode = p.Name,
|
||||
Url = p.PublicUrl,
|
||||
StaticUrl = p.PublicUrl, //TODO
|
||||
VisibleInPicker = true
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(res);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue