[backend/masto-client] Add note favourites & bookmarks endpoints (ISH-99, ISH-100)
This commit is contained in:
parent
644fed46eb
commit
cda90302e1
1 changed files with 35 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Mime;
|
||||
using Iceshrimp.Backend.Controllers.Attributes;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Attributes;
|
||||
|
@ -277,6 +278,40 @@ public class AccountController(
|
|||
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
[HttpGet("/api/v1/favourites")]
|
||||
[Authorize("read:favourites")]
|
||||
[LinkPagination(20, 40)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<StatusEntity>))]
|
||||
[SuppressMessage("ReSharper", "EntityFramework.UnsupportedServerSideFunctionCall", Justification = "Projectables")]
|
||||
public async Task<IActionResult> GetLikedNotes(MastodonPaginationQuery query)
|
||||
{
|
||||
var user = HttpContext.GetUserOrFail();
|
||||
var res = await db.Notes
|
||||
.Where(p => db.Users.First(u => u == user).HasLiked(p))
|
||||
.IncludeCommonProperties()
|
||||
.Paginate(query, ControllerContext)
|
||||
.RenderAllForMastodonAsync(noteRenderer, user);
|
||||
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
[HttpGet("/api/v1/bookmarks")]
|
||||
[Authorize("read:bookmarks")]
|
||||
[LinkPagination(20, 40)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<StatusEntity>))]
|
||||
[SuppressMessage("ReSharper", "EntityFramework.UnsupportedServerSideFunctionCall", Justification = "Projectables")]
|
||||
public async Task<IActionResult> GetBookmarkedNotes(MastodonPaginationQuery query)
|
||||
{
|
||||
var user = HttpContext.GetUserOrFail();
|
||||
var res = await db.Notes
|
||||
.Where(p => db.Users.First(u => u == user).HasBookmarked(p))
|
||||
.IncludeCommonProperties()
|
||||
.Paginate(query, ControllerContext)
|
||||
.RenderAllForMastodonAsync(noteRenderer, user);
|
||||
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
[HttpPost("/api/v1/follow_requests/{id}/authorize")]
|
||||
[Authorize("write:follows")]
|
||||
|
|
Loading…
Add table
Reference in a new issue