Added nsfw in group profile editor.

This commit is contained in:
CakeAndBanana
2025-10-19 16:55:42 +02:00
parent 280c80d89f
commit edb7232b17
4 changed files with 26 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
namespace LightlessSync.Services;
public record LightlessGroupProfileData(string Base64ProfilePicture, string Description, string Tags)
public record LightlessGroupProfileData(string Base64ProfilePicture, string Description, string Tags, bool IsNsfw, bool IsDisabled)
{
public Lazy<byte[]> ImageData { get; } = new Lazy<byte[]>(Convert.FromBase64String(Base64ProfilePicture));
}

View File

@@ -20,6 +20,7 @@ public class LightlessProfileManager : MediatorSubscriberBase
private const string _noGroupDescription = "-- Syncshell has no description set --";
private const string _noTags = "-- Syncshell has no tags set --";
private const string _nsfwDescription = "Profile not displayed - NSFW";
private readonly ApiController _apiController;
private readonly ILogger<LightlessProfileManager> _logger;
private readonly LightlessConfigService _lightlessConfigService;
@@ -28,9 +29,10 @@ public class LightlessProfileManager : MediatorSubscriberBase
private readonly LightlessUserProfileData _defaultProfileUserData = new(IsFlagged: false, IsNSFW: false, _lightlessLogo, string.Empty, _noUserDescription);
private readonly LightlessUserProfileData _loadingProfileUserData = new(IsFlagged: false, IsNSFW: false, _lightlessLogoLoading, string.Empty, "Loading User Profile Data from server...");
private readonly LightlessGroupProfileData _loadingProfileGroupData = new(_lightlessLogoLoading, "Loading Syncshell Profile Data from server...", string.Empty);
private readonly LightlessGroupProfileData _defaultProfileGroupData = new(_lightlessLogo, _noGroupDescription, string.Empty);
private readonly LightlessUserProfileData _nsfwProfileUserData = new(IsFlagged: false, IsNSFW: false, _lightlessLogoNsfw, string.Empty, _nsfwDescription);
private readonly LightlessGroupProfileData _loadingProfileGroupData = new(_lightlessLogoLoading, "Loading Syncshell Profile Data from server...", string.Empty, IsNsfw: false, IsDisabled: false);
private readonly LightlessGroupProfileData _defaultProfileGroupData = new(_lightlessLogo, _noGroupDescription, string.Empty, IsNsfw: false, IsDisabled: false);
private readonly LightlessUserProfileData _nsfwProfileUserData = new(IsFlagged: false, IsNSFW: true, _lightlessLogoNsfw, string.Empty, _nsfwDescription);
private readonly LightlessGroupProfileData _nsfwProfileGroupData = new(_lightlessLogoNsfw, string.Empty, _nsfwDescription, IsNsfw: false, IsDisabled: false);
public LightlessProfileManager(ILogger<LightlessProfileManager> logger, LightlessConfigService lightlessConfigService,
@@ -164,9 +166,18 @@ public class LightlessProfileManager : MediatorSubscriberBase
LightlessGroupProfileData profileGroupData = new(Base64ProfilePicture: string.IsNullOrEmpty(profile.PictureBase64) ? _lightlessLogo : profile.PictureBase64,
Description: string.IsNullOrEmpty(profile.Description) ? _noGroupDescription : profile.Description,
Tags: string.IsNullOrEmpty(profile.Tags) ? _noTags : profile.Tags);
Tags: string.IsNullOrEmpty(profile.Tags) ? _noTags : profile.Tags,
profile.IsNsfw ?? false, profile.IsDisabled ?? false);
_logger.LogTrace("Replacing data in _lightlessGroupProfiles for Group {data}", data.AliasOrGID);
if (profileGroupData.IsNsfw && !_lightlessConfigService.Current.ProfilesAllowNsfw)
{
_lightlessGroupProfiles[data] = _nsfwProfileGroupData;
}
else
{
_lightlessGroupProfiles[data] = profileGroupData;
}
_lightlessGroupProfiles[data] = profileGroupData;
}
catch (Exception ex)