mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-27 16:09:07 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RadicadeServer.DB;
|
||||
using RadicadeServer.Extensions;
|
||||
using RadicadeServer.RecNet.Enums.Rooms;
|
||||
using RadicadeServer.RecNet.Responses;
|
||||
using RadicadeServer.RecNet.Rooms;
|
||||
using RadicadeServer.Utils;
|
||||
|
||||
namespace RadicadeServer.API.Rooms.V1
|
||||
{
|
||||
[Route("api/rooms/v1")]
|
||||
public class RoomsV1 : Controller
|
||||
{
|
||||
RecDBContext db;
|
||||
public RoomsV1(RecDBContext context)
|
||||
{
|
||||
this.db = context;
|
||||
}
|
||||
|
||||
[HttpGet("filters")]
|
||||
public async Task<ActionResult<RoomFilters>> GetRoomFilters()
|
||||
{
|
||||
var dbFilters = await db.ServerConfig.FirstOrDefaultAsync(x => x.Key == "Filters");
|
||||
if (dbFilters == null)
|
||||
return NotFound();
|
||||
|
||||
var filters = dbFilters.Value.Split(',', StringSplitOptions.TrimEntries).ToList();
|
||||
|
||||
return new RoomFilters { PinnedFilters = filters , PopularFilters = filters, TrendingFilters = filters };
|
||||
}
|
||||
|
||||
[HttpPost("verifyRole"), Authorize]
|
||||
public async Task<Success?> VerifyRole([FromForm] long roomId, [FromForm] RoleType role, [FromForm] string? context)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
|
||||
var roomRole = await RoomUtils.VerifyRole((long)userId!, roomId, role);
|
||||
|
||||
if (!roomRole)
|
||||
return new Success(false, "Invalid roles", false);
|
||||
else
|
||||
return new Success(true, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user