fix moderators + profiles
This commit is contained in:
@@ -211,7 +211,8 @@ public partial class LightlessHub
|
|||||||
|
|
||||||
if (isOwnerResult.ReferredGroup == null) return (false, null);
|
if (isOwnerResult.ReferredGroup == null) return (false, null);
|
||||||
|
|
||||||
var groupPairSelf = await DbContext.GroupPairs.SingleOrDefaultAsync(g => g.GroupGID == gid || g.Group.Alias == gid && g.GroupUserUID == UserUID).ConfigureAwait(false);
|
var groupPairSelf = await DbContext.GroupPairs.SingleOrDefaultAsync(
|
||||||
|
g => (g.GroupGID == gid || g.Group.Alias == gid) && g.GroupUserUID == UserUID).ConfigureAwait(false);
|
||||||
if (groupPairSelf == null || !groupPairSelf.IsModerator) return (false, null);
|
if (groupPairSelf == null || !groupPairSelf.IsModerator) return (false, null);
|
||||||
|
|
||||||
return (true, isOwnerResult.ReferredGroup);
|
return (true, isOwnerResult.ReferredGroup);
|
||||||
|
|||||||
@@ -799,8 +799,8 @@ public partial class LightlessHub
|
|||||||
if (!hasRights) return;
|
if (!hasRights) return;
|
||||||
|
|
||||||
var groupProfileDb = await DbContext.GroupProfiles
|
var groupProfileDb = await DbContext.GroupProfiles
|
||||||
.FirstOrDefaultAsync(g => g.Group.GID == dto.Group.GID || g.Group.Alias == dto.Group.GID,
|
.Include(g => g.Group)
|
||||||
cancellationToken)
|
.FirstOrDefaultAsync(g => g.GroupGID == dto.Group.GID, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
ImageCheckService.ImageLoadResult profileResult = null;
|
ImageCheckService.ImageLoadResult profileResult = null;
|
||||||
@@ -830,27 +830,33 @@ public partial class LightlessHub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sanitizedProfileImage = profileResult?.Base64Image;
|
||||||
|
var sanitizedBannerImage = bannerResult?.Base64Image;
|
||||||
|
|
||||||
if (groupProfileDb == null)
|
if (groupProfileDb == null)
|
||||||
{
|
{
|
||||||
groupProfileDb = new GroupProfile
|
groupProfileDb = new GroupProfile
|
||||||
{
|
{
|
||||||
GroupGID = dto.Group.GID,
|
GroupGID = dto.Group.GID,
|
||||||
|
Group = group,
|
||||||
ProfileDisabled = false,
|
ProfileDisabled = false,
|
||||||
IsNSFW = dto.IsNsfw ?? false,
|
IsNSFW = dto.IsNsfw ?? false,
|
||||||
};
|
};
|
||||||
|
|
||||||
groupProfileDb.UpdateProfileFromDto(dto, profileResult.Base64Image, bannerResult.Base64Image);
|
groupProfileDb.UpdateProfileFromDto(dto, sanitizedProfileImage, sanitizedBannerImage);
|
||||||
await DbContext.GroupProfiles.AddAsync(groupProfileDb, cancellationToken).ConfigureAwait(false);
|
await DbContext.GroupProfiles.AddAsync(groupProfileDb, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
groupProfileDb.Group ??= group;
|
||||||
|
|
||||||
if (groupProfileDb?.ProfileDisabled ?? false)
|
if (groupProfileDb?.ProfileDisabled ?? false)
|
||||||
{
|
{
|
||||||
await Clients.Caller.Client_ReceiveServerMessage(MessageSeverity.Error, "Your profile was permanently disabled and cannot be edited").ConfigureAwait(false);
|
await Clients.Caller.Client_ReceiveServerMessage(MessageSeverity.Error, "Your profile was permanently disabled and cannot be edited").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
groupProfileDb.UpdateProfileFromDto(dto, profileResult.Base64Image, bannerResult.Base64Image);
|
groupProfileDb.UpdateProfileFromDto(dto, sanitizedProfileImage, sanitizedBannerImage);
|
||||||
|
|
||||||
var userIds = await DbContext.GroupPairs
|
var userIds = await DbContext.GroupPairs
|
||||||
.Where(p => p.GroupGID == groupProfileDb.GroupGID)
|
.Where(p => p.GroupGID == groupProfileDb.GroupGID)
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ public static class Extensions
|
|||||||
return new GroupProfileDto(Group: null, Description: null, Tags: null, PictureBase64: null, BannerBase64: null, IsNsfw: false, IsDisabled: false);
|
return new GroupProfileDto(Group: null, Description: null, Tags: null, PictureBase64: null, BannerBase64: null, IsNsfw: false, IsDisabled: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var groupData = groupProfile.Group?.ToGroupData();
|
var groupData = groupProfile.Group?.ToGroupData()
|
||||||
|
?? (!string.IsNullOrWhiteSpace(groupProfile.GroupGID) ? new GroupData(groupProfile.GroupGID) : null);
|
||||||
|
|
||||||
return new GroupProfileDto(
|
return new GroupProfileDto(
|
||||||
groupData,
|
groupData,
|
||||||
|
|||||||
Reference in New Issue
Block a user