[backend/api] Add endpoint for deleting emojis
This commit is contained in:
parent
6743442ce8
commit
af376ffbe5
2 changed files with 24 additions and 0 deletions
|
@ -278,4 +278,15 @@ public class AdminController(
|
|||
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
[HttpDelete("emoji/{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(string))]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))]
|
||||
public async Task<IActionResult> DeleteEmoji(string id)
|
||||
{
|
||||
var emojiId = await emojiSvc.DeleteEmoji(id);
|
||||
if (emojiId == null) return NotFound();
|
||||
|
||||
return Ok(emojiId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,19 @@ public partial class EmojiService(DatabaseContext db, DriveService driveSvc, Sys
|
|||
return emoji;
|
||||
}
|
||||
|
||||
public async Task<string?> DeleteEmoji(string id)
|
||||
{
|
||||
var emoji = await db.Emojis.FirstOrDefaultAsync(p => p.Id == id);
|
||||
if (emoji == null) return null;
|
||||
|
||||
var emojiId = emoji.Id;
|
||||
|
||||
db.Remove(emoji);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return emojiId;
|
||||
}
|
||||
|
||||
public async Task<List<Emoji>> ProcessEmojiAsync(List<ASEmoji>? emoji, string host)
|
||||
{
|
||||
emoji?.RemoveAll(p => p.Name == null);
|
||||
|
|
Loading…
Add table
Reference in a new issue