a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/web] Add endpoint for batch updating emojis

authored by

pancakes and committed by
Iceshrimp development
2a39018d 83d5fceb

+50 -5
+37
Iceshrimp.Backend/Controllers/Web/EmojiController.cs
··· 4 4 using Iceshrimp.Backend.Controllers.Shared.Schemas; 5 5 using Iceshrimp.Backend.Core.Configuration; 6 6 using Iceshrimp.Backend.Core.Database; 7 + using Iceshrimp.Backend.Core.Database.Tables; 7 8 using Iceshrimp.Backend.Core.Extensions; 8 9 using Iceshrimp.Backend.Core.Middleware; 9 10 using Iceshrimp.Backend.Core.Services; ··· 231 232 public async Task DeleteEmoji(string id) 232 233 { 233 234 await emojiSvc.DeleteEmojiAsync(id); 235 + } 236 + 237 + [HttpPatch("batch")] 238 + [Authorize("role:moderator")] 239 + [Consumes(MediaTypeNames.Application.Json)] 240 + [ProducesResults(HttpStatusCode.OK)] 241 + [ProducesErrors(HttpStatusCode.BadRequest, HttpStatusCode.NotFound)] 242 + public async Task<List<EmojiResponse>> BatchUpdateEmoji(BatchUpdateEmojiRequest request) 243 + { 244 + var ids = await db.Emojis.Where(p => request.Ids.Contains(p.Id) && p.Host == null) 245 + .Select(p => p.Id) 246 + .ToListAsync(); 247 + 248 + if (ids.Count == 0) throw GracefulException.BadRequest("No valid emoji ids were provided"); 249 + 250 + var emojis = new List<Emoji>(); 251 + 252 + foreach (var id in ids) 253 + { 254 + var emoji = await emojiSvc.UpdateLocalEmojiAsync(id, null, null, request.Category, 255 + request.License, request.Sensitive); 256 + if (emoji != null) emojis.Add(emoji); 257 + } 258 + 259 + return emojis.Select(p => new EmojiResponse 260 + { 261 + Id = p.Id, 262 + Name = p.Name, 263 + Uri = p.Uri, 264 + Tags = p.Tags, 265 + Category = p.Category, 266 + PublicUrl = p.GetAccessUrl(instance.Value), 267 + License = p.License, 268 + Sensitive = p.Sensitive 269 + }) 270 + .ToList(); 234 271 } 235 272 }
+13 -5
Iceshrimp.Shared/Schemas/Web/UpdateEmojiRequest.cs
··· 2 2 3 3 public class UpdateEmojiRequest 4 4 { 5 - public string? Name { get; set; } 6 - public List<string>? Tags { get; set; } 7 - public string? Category { get; set; } 8 - public string? License { get; set; } 9 - public bool? Sensitive { get; set; } 5 + public string? Name { get; set; } 6 + public List<string>? Tags { get; set; } 7 + public string? Category { get; set; } 8 + public string? License { get; set; } 9 + public bool? Sensitive { get; set; } 10 10 } 11 + 12 + public class BatchUpdateEmojiRequest 13 + { 14 + public required List<string> Ids { get; set; } 15 + public string? Category { get; set; } 16 + public string? License { get; set; } 17 + public bool? Sensitive { get; set; } 18 + }