diff --git a/LightlessSync/Services/LightlessGroupProfileData.cs b/LightlessSync/Services/LightlessGroupProfileData.cs index 5a4c01a..2a42e0a 100644 --- a/LightlessSync/Services/LightlessGroupProfileData.cs +++ b/LightlessSync/Services/LightlessGroupProfileData.cs @@ -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 ImageData { get; } = new Lazy(Convert.FromBase64String(Base64ProfilePicture)); } diff --git a/LightlessSync/Services/LightlessProfileManager.cs b/LightlessSync/Services/LightlessProfileManager.cs index dde664b..69ad8e7 100644 --- a/LightlessSync/Services/LightlessProfileManager.cs +++ b/LightlessSync/Services/LightlessProfileManager.cs @@ -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 _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 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) diff --git a/LightlessSync/UI/SyncshellAdminUI.cs b/LightlessSync/UI/SyncshellAdminUI.cs index 141510b..6391043 100644 --- a/LightlessSync/UI/SyncshellAdminUI.cs +++ b/LightlessSync/UI/SyncshellAdminUI.cs @@ -300,7 +300,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase } _showFileDialogError = false; - await _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, Convert.ToBase64String(fileContent))) + await _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, Convert.ToBase64String(fileContent), IsNsfw: null, IsDisabled: null)) .ConfigureAwait(false); } }); @@ -310,7 +310,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase ImGui.SameLine(); if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear uploaded profile picture")) { - _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null)); + _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null, IsNsfw: null, IsDisabled: null)); } UiSharedService.AttachToolTip("Clear your currently uploaded profile picture"); if (_showFileDialogError) @@ -361,21 +361,21 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Description")) { - _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: _descriptionText, Tags: null, PictureBase64: null)); + _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: _descriptionText, Tags: null, PictureBase64: null, IsNsfw: null, IsDisabled: null)); } UiSharedService.AttachToolTip("Sets your profile description text"); ImGui.SameLine(); if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear Description")) { - _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null)); + _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null, IsNsfw: null, IsDisabled: null)); } UiSharedService.AttachToolTip("Clears your profile description text"); ImGui.Separator(); ImGui.TextUnformatted($"Profile Options:"); - var isNsfw = false; + var isNsfw = _profileData.; if (ImGui.Checkbox("Profile is NSFW", ref isNsfw)) { - _ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, isNsfw, ProfilePictureBase64: null, Description: null)); + _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null, IsNsfw: isNsfw, IsDisabled: null)); } _uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON"); ImGui.TreePop(); @@ -734,15 +734,15 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase { if (HasTag) { - _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null)); + _ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null, IsNsfw: null, IsDisabled: null)); _selectedTags.Add(tag); } else { _ = _selectedTags.Count > 0 - ? _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null)) - : _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: string.Empty, PictureBase64: null)); + ? _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null, IsNsfw: null, IsDisabled: null)) + : _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: string.Empty, PictureBase64: null, IsNsfw: null, IsDisabled: null)); _selectedTags.Remove(tag); } diff --git a/LightlessSync/WebAPI/SignalR/ApiController.Functions.Groups.cs b/LightlessSync/WebAPI/SignalR/ApiController.Functions.Groups.cs index 79de11e..95bb8e2 100644 --- a/LightlessSync/WebAPI/SignalR/ApiController.Functions.Groups.cs +++ b/LightlessSync/WebAPI/SignalR/ApiController.Functions.Groups.cs @@ -117,7 +117,7 @@ public partial class ApiController } public async Task GroupGetProfile(GroupDto dto) { - if (!IsConnected) return new GroupProfileDto(Group: dto.Group, Description: null, Tags: null, PictureBase64: null); + if (!IsConnected) return new GroupProfileDto(Group: dto.Group, Description: null, Tags: null, PictureBase64: null, IsNsfw: false, IsDisabled: false); return await _lightlessHub!.InvokeAsync(nameof(GroupGetProfile), dto).ConfigureAwait(false); }