Added nsfw in group profile editor.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public partial class ApiController
|
||||
}
|
||||
public async Task<GroupProfileDto> 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<GroupProfileDto>(nameof(GroupGetProfile), dto).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user