Reworked syncshell profile and user profile calls. #21

Merged
defnotken merged 11 commits from syncshell-profiles-attempt-two into master 2025-10-19 19:41:38 +00:00
2 changed files with 19 additions and 3 deletions
Showing only changes of commit bab81aaf51 - Show all commits

View File

@@ -746,14 +746,19 @@ public partial class LightlessHub
var cancellationToken = RequestAbortedToken;
var data = await DbContext.GroupProfiles
.FirstOrDefaultAsync(g => g.Group.ToGroupData().AliasOrGID == dto.Group.AliasOrGID, cancellationToken)
.FirstOrDefaultAsync(g => g.Group.GID == dto.Group.GID || g.Group.Alias == dto.Group.AliasOrGID, cancellationToken)
.ConfigureAwait(false);
var profileDto = new GroupProfileDto(dto.Group, Description: null, Tags: null, PictureBase64: null, IsNsfw: false, IsDisabled: false);
if (data is not null)
{
profileDto = data.ToDTO();
_logger.LogCallInfo(LightlessHubLogger.Args($"GroupGetProfile: dto={dto?.GID}, groupProfile.Group={(data?.Group != null)}"));
if (data.Group != null)
{
profileDto = data.ToDTO();
}
}
return profileDto;

View File

@@ -11,7 +11,18 @@ public static class Extensions
{
public static GroupProfileDto ToDTO(this GroupProfile groupProfile)
{
return new GroupProfileDto(groupProfile.Group.ToGroupData(), groupProfile.Description, groupProfile.Tags, groupProfile.Base64GroupProfileImage, groupProfile.IsNSFW, groupProfile.ProfileDisabled);
ArgumentNullException.ThrowIfNull(groupProfile);
return groupProfile.Group == null
? throw new InvalidOperationException("GroupProfile.Group is null when converting to DTO.")
: new GroupProfileDto(
groupProfile.Group.ToGroupData(),
groupProfile.Description,
groupProfile.Tags,
groupProfile.Base64GroupProfileImage,
groupProfile.IsNSFW,
groupProfile.ProfileDisabled
);
}
public static GroupData ToGroupData(this Group group)