From b84d6c35d63952472e9823e3c6702abb8e7c6624 Mon Sep 17 00:00:00 2001 From: cake Date: Mon, 27 Oct 2025 19:08:25 +0100 Subject: [PATCH] Moved notification on groups on new ones, Fixed new creation of profiles. --- .../Hubs/LightlessHub.Groups.cs | 22 +++++++++---------- .../Hubs/LightlessHub.User.cs | 18 +++++++-------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.Groups.cs b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.Groups.cs index e31e482..cd7afdc 100644 --- a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.Groups.cs +++ b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.Groups.cs @@ -857,19 +857,19 @@ public partial class LightlessHub } groupProfileDb.UpdateProfileFromDto(dto, sanitizedProfileImage, sanitizedBannerImage); + } - var userIds = await DbContext.GroupPairs - .Where(p => p.GroupGID == groupProfileDb.GroupGID) - .Select(p => p.GroupUserUID) - .ToListAsync(cancellationToken) + var userIds = await DbContext.GroupPairs + .Where(p => p.GroupGID == groupProfileDb.GroupGID) + .Select(p => p.GroupUserUID) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + + if (userIds.Count > 0) + { + var profileDto = groupProfileDb.ToDTO(); + await Clients.Users(userIds).Client_GroupSendProfile(profileDto) .ConfigureAwait(false); - - if (userIds.Count > 0) - { - var profileDto = groupProfileDb.ToDTO(); - await Clients.Users(userIds).Client_GroupSendProfile(profileDto) - .ConfigureAwait(false); - } } await DbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false); diff --git a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs index b40cc57..b4358bb 100644 --- a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs +++ b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs @@ -1128,7 +1128,7 @@ public partial class LightlessHub if (!string.Equals(dto.User.UID, UserUID, StringComparison.Ordinal)) throw new HubException("Cannot modify profile data for anyone but yourself"); - var existingData = await DbContext.UserProfileData.SingleOrDefaultAsync(u => u.UserUID == dto.User.UID, cancellationToken: RequestAbortedToken).ConfigureAwait(false); + var profileData = await DbContext.UserProfileData.SingleOrDefaultAsync(u => u.UserUID == dto.User.UID, cancellationToken: RequestAbortedToken).ConfigureAwait(false); ImageCheckService.ImageLoadResult profileResult = new(); ImageCheckService.ImageLoadResult bannerResult = new(); @@ -1157,35 +1157,33 @@ public partial class LightlessHub } } - if (existingData != null) + if (profileData != null) { - if (existingData.FlaggedForReport) + if (profileData.FlaggedForReport) { await Clients.Caller.Client_ReceiveServerMessage(MessageSeverity.Error, "Your profile is currently flagged for report and cannot be edited").ConfigureAwait(false); return; } - if (existingData.ProfileDisabled) + if (profileData.ProfileDisabled) { await Clients.Caller.Client_ReceiveServerMessage(MessageSeverity.Error, "Your profile was permanently disabled and cannot be edited").ConfigureAwait(false); return; } - existingData.UpdateProfileFromDto(dto, profileResult.Base64Image, bannerResult.Base64Image); + profileData.UpdateProfileFromDto(dto, profileResult.Base64Image, bannerResult.Base64Image); } else { - UserProfileData newUserProfileData = new() + profileData = new() { UserUID = dto.User.UID, - Base64ProfileImage = dto.ProfilePictureBase64 ?? null, - UserDescription = dto.Description ?? null, IsNSFW = dto.IsNSFW ?? false, }; - existingData.UpdateProfileFromDto(dto, profileResult.Base64Image, bannerResult.Base64Image); + profileData.UpdateProfileFromDto(dto, profileResult.Base64Image, bannerResult.Base64Image); - await DbContext.UserProfileData.AddAsync(newUserProfileData, cancellationToken).ConfigureAwait(false); + await DbContext.UserProfileData.AddAsync(profileData, cancellationToken).ConfigureAwait(false); } -- 2.49.1