[backend/api] Allow updating remote emojis but limited to sensitive status
This commit is contained in:
parent
d160d7337e
commit
af580eeed1
2 changed files with 14 additions and 2 deletions
|
@ -206,7 +206,7 @@ public class EmojiController(
|
|||
[Authorize("role:moderator")]
|
||||
[Consumes(MediaTypeNames.Application.Json)]
|
||||
[ProducesResults(HttpStatusCode.OK)]
|
||||
[ProducesErrors(HttpStatusCode.NotFound)]
|
||||
[ProducesErrors(HttpStatusCode.BadRequest, HttpStatusCode.NotFound)]
|
||||
public async Task<EmojiResponse> UpdateEmoji(string id, UpdateEmojiRequest request)
|
||||
{
|
||||
var emoji = await emojiSvc.UpdateLocalEmojiAsync(id, request.Name, request.Tags, request.Category,
|
||||
|
|
|
@ -229,7 +229,19 @@ public partial class EmojiService(
|
|||
{
|
||||
var emoji = await db.Emojis.FirstOrDefaultAsync(p => p.Id == id);
|
||||
if (emoji == null) return null;
|
||||
if (emoji.Host != null) return null;
|
||||
|
||||
if (emoji.Host != null)
|
||||
{
|
||||
// Only allow changing remote emoji sensitive status
|
||||
if (!sensitive.HasValue)
|
||||
throw GracefulException.BadRequest("Only sensitive can be updated on remote emojis");
|
||||
|
||||
emoji.Sensitive = sensitive.Value;
|
||||
emoji.UpdatedAt = DateTime.UtcNow;
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return emoji;
|
||||
}
|
||||
|
||||
emoji.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue