mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-01 22:18:46 +00:00
cs: create uapi project
Build docker images / build (api) (push) Failing after 26s
Build docker images / build (cdn) (push) Failing after 26s
Build docker images / build (default) (push) Failing after 25s
Build docker images / build (gateway) (push) Failing after 38s
Build docker images / build (gateway-offload) (push) Failing after 26s
Build docker images / build (admin-api) (push) Failing after 4m11s
Style / build (24.x) (push) Failing after 45s
Build / build (24.x) (push) Failing after 42s
Nix build / build-nix (push) Failing after 20s
Build docker images / build (cdn-cs) (push) Failing after 26s
Build docker images / build (api) (push) Failing after 26s
Build docker images / build (cdn) (push) Failing after 26s
Build docker images / build (default) (push) Failing after 25s
Build docker images / build (gateway) (push) Failing after 38s
Build docker images / build (gateway-offload) (push) Failing after 26s
Build docker images / build (admin-api) (push) Failing after 4m11s
Style / build (24.x) (push) Failing after 45s
Build / build (24.x) (push) Failing after 42s
Nix build / build-nix (push) Failing after 20s
Build docker images / build (cdn-cs) (push) Failing after 26s
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Spacebar.Interop.Authentication.AspNetCore;
|
||||
using Spacebar.Models.Db.Contexts;
|
||||
using Spacebar.DataMappings.Generic;
|
||||
using Spacebar.Models.Generic;
|
||||
|
||||
namespace Spacebar.UApi.Controllers;
|
||||
|
||||
[Route("/api/v{_}/guilds/{guildId}/members/")]
|
||||
public class GuildMembersController(ILogger<GuildMembersController> logger, SpacebarDbContext db, SpacebarAspNetAuthenticationService authService) : ControllerBase {
|
||||
/// <summary>
|
||||
/// Get a guild member by ID
|
||||
/// </summary>
|
||||
/// <param name="guildId">Guild ID</param>
|
||||
/// <param name="memberId">Member ID</param>
|
||||
/// <returns>The public member projection</returns>
|
||||
/// <exception cref="InvalidOperationException">An error has occured</exception>
|
||||
[HttpGet("{memberId}")]
|
||||
public async Task<Member> GetMemberAsync(string guildId, string memberId) {
|
||||
var user = await authService.GetCurrentUserAsync(Request);
|
||||
var cmember = db.Members.SingleOrDefault(x => x.Id == user.Id && x.GuildId == guildId);
|
||||
if (cmember is null)
|
||||
throw new InvalidOperationException("You are not a member of this guild.");
|
||||
|
||||
var member = db.Members
|
||||
.Include(x => x.IdNavigation) // User object
|
||||
.Include(x => x.Roles)
|
||||
.SingleOrDefault(x => x.Id == user.Id && x.GuildId == guildId);
|
||||
|
||||
if (member is null)
|
||||
throw new InvalidOperationException("Member not found");
|
||||
|
||||
return member.ToPublicMember();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user