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/api] Add instance staff endpoint

authored by

pancakes and committed by
Iceshrimp development
28b3b566 b6dddd94

+50
+40
Iceshrimp.Backend/Controllers/Web/InstanceController.cs
··· 1 + using System.Net; 2 + using System.Net.Mime; 3 + using Iceshrimp.Backend.Controllers.Shared.Attributes; 4 + using Iceshrimp.Backend.Controllers.Web.Renderers; 5 + using Iceshrimp.Backend.Core.Database; 6 + using Iceshrimp.Backend.Core.Extensions; 7 + using Iceshrimp.Backend.Core.Middleware; 8 + using Iceshrimp.Shared.Schemas.Web; 9 + using Microsoft.AspNetCore.Mvc; 10 + using Microsoft.AspNetCore.RateLimiting; 11 + 12 + namespace Iceshrimp.Backend.Controllers.Web; 13 + 14 + [ApiController] 15 + [EnableRateLimiting("sliding")] 16 + [Route("/api/iceshrimp/instance")] 17 + [Produces(MediaTypeNames.Application.Json)] 18 + public class InstanceController(DatabaseContext db, UserRenderer userRenderer) : ControllerBase 19 + { 20 + [HttpGet("staff")] 21 + [Authenticate] 22 + [Authorize] 23 + [ProducesResults(HttpStatusCode.OK)] 24 + public async Task<StaffResponse> GetStaff() 25 + { 26 + var admins = db.Users 27 + .Where(p => p.IsAdmin == true) 28 + .OrderBy(p => p.UsernameLower); 29 + var adminList = await userRenderer.RenderMany(admins) 30 + .ToListAsync(); 31 + 32 + var moderators = db.Users 33 + .Where(p => p.IsAdmin == false && p.IsModerator == true) 34 + .OrderBy(p => p.UsernameLower); 35 + var moderatorList = await userRenderer.RenderMany(moderators) 36 + .ToListAsync(); 37 + 38 + return new StaffResponse { Admins = adminList, Moderators = moderatorList }; 39 + } 40 + }
+10
Iceshrimp.Shared/Schemas/Web/InstanceResponse.cs
··· 1 + namespace Iceshrimp.Shared.Schemas.Web; 2 + 3 + // TODO: Instance Response for /api/iceshrimp/instance 4 + public class InstanceResponse { } 5 + 6 + public class StaffResponse 7 + { 8 + public required List<UserResponse> Admins { get; set; } 9 + public required List<UserResponse> Moderators { get; set; } 10 + }