fix group vanity gid cleanup

This commit is contained in:
Stanley Dimant
2024-12-21 18:00:59 +01:00
parent 010fcb0d2e
commit 600bd1893e

View File

@@ -265,10 +265,10 @@ internal class DiscordBot : IHostedService
private async Task CheckVanityForGroup(RestGuild restGuild, Dictionary<ulong, string> allowedRoleIds, MareDbContext db, Group group, CancellationToken token) private async Task CheckVanityForGroup(RestGuild restGuild, Dictionary<ulong, string> allowedRoleIds, MareDbContext db, Group group, CancellationToken token)
{ {
var groupPrimaryUser = group.OwnerUID; var groupPrimaryUser = group.OwnerUID;
var primaryUser = await db.Auth.Include(u => u.User).SingleOrDefaultAsync(u => u.PrimaryUserUID == group.OwnerUID).ConfigureAwait(false); var groupOwner = await db.Auth.Include(u => u.User).SingleOrDefaultAsync(u => u.UserUID == group.OwnerUID).ConfigureAwait(false);
if (primaryUser != null) if (groupOwner != null && !string.IsNullOrEmpty(groupOwner.PrimaryUserUID))
{ {
groupPrimaryUser = primaryUser.User.UID; groupPrimaryUser = groupOwner.PrimaryUserUID;
} }
var lodestoneUser = await db.LodeStoneAuth.Include(u => u.User).SingleOrDefaultAsync(f => f.User.UID == groupPrimaryUser).ConfigureAwait(false); var lodestoneUser = await db.LodeStoneAuth.Include(u => u.User).SingleOrDefaultAsync(f => f.User.UID == groupPrimaryUser).ConfigureAwait(false);