feat(api): try harder at checking whether user is in guild

This commit is contained in:
alyssa 2025-06-08 20:27:35 +00:00
parent 539fc82342
commit 6fea94f990
4 changed files with 45 additions and 11 deletions

View file

@ -7,4 +7,5 @@ public class ApiConfig
public string? ClientSecret { get; set; }
public bool TrustAuth { get; set; } = false;
public string? AvatarServiceUrl { get; set; }
public bool SearchGuildSettings = false;
}

View file

@ -20,7 +20,7 @@ public class DiscordControllerV2: PKControllerBase
if (ContextFor(system) != LookupContext.ByOwner)
throw Errors.GenericMissingPermissions;
var settings = await _repo.GetSystemGuild(guild_id, system.Id, false);
var settings = await _repo.GetSystemGuild(guild_id, system.Id, false, _config.SearchGuildSettings);
if (settings == null)
throw Errors.SystemGuildNotFound;
@ -34,7 +34,7 @@ public class DiscordControllerV2: PKControllerBase
if (ContextFor(system) != LookupContext.ByOwner)
throw Errors.GenericMissingPermissions;
var settings = await _repo.GetSystemGuild(guild_id, system.Id, false);
var settings = await _repo.GetSystemGuild(guild_id, system.Id, false, _config.SearchGuildSettings);
if (settings == null)
throw Errors.SystemGuildNotFound;
@ -58,7 +58,7 @@ public class DiscordControllerV2: PKControllerBase
if (member.System != system.Id)
throw Errors.NotOwnMemberError;
var settings = await _repo.GetMemberGuild(guild_id, member.Id, false);
var settings = await _repo.GetMemberGuild(guild_id, member.Id, false, _config.SearchGuildSettings ? system.Id : null);
if (settings == null)
throw Errors.MemberGuildNotFound;
@ -75,7 +75,7 @@ public class DiscordControllerV2: PKControllerBase
if (member.System != system.Id)
throw Errors.NotOwnMemberError;
var settings = await _repo.GetMemberGuild(guild_id, member.Id, false);
var settings = await _repo.GetMemberGuild(guild_id, member.Id, false, _config.SearchGuildSettings ? system.Id : null);
if (settings == null)
throw Errors.MemberGuildNotFound;