From eafdce528f49051eff8ce4f79c3c4ec82b561f12 Mon Sep 17 00:00:00 2001 From: Harshith Mohan <26010946+harshithmohan@users.noreply.github.com> Date: Fri, 13 Sep 2024 19:32:32 +0530 Subject: [PATCH] API v3 User DTO: expose `PlexUsernames` as comma-separated string instead of `List` --- Shoko.Server/API/v3/Models/Shoko/User.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Shoko.Server/API/v3/Models/Shoko/User.cs b/Shoko.Server/API/v3/Models/Shoko/User.cs index e1eaae984..85eebc634 100644 --- a/Shoko.Server/API/v3/Models/Shoko/User.cs +++ b/Shoko.Server/API/v3/Models/Shoko/User.cs @@ -53,7 +53,7 @@ public class User /// /// The user's Plex usernames. /// - public List PlexUsernames { get; set; } + public string PlexUsernames { get; set; } public User(SVR_JMMUser user) { @@ -84,7 +84,7 @@ public User(SVR_JMMUser user) Avatar = user.HasAvatarImage ? ModelHelper.ToDataURL(user.AvatarImageBlob, user.AvatarImageMetadata.ContentType) ?? string.Empty : string.Empty; - PlexUsernames = user.PlexUsers?.Split(',', System.StringSplitOptions.RemoveEmptyEntries | System.StringSplitOptions.TrimEntries).ToList() ?? []; + PlexUsernames = user.PlexUsers ?? string.Empty; } public class Input @@ -149,7 +149,7 @@ public class CreateOrUpdateUserBody /// /// The new user's Plex usernames. /// - public List? PlexUsernames { get; set; } + public string? PlexUsernames { get; set; } public CreateOrUpdateUserBody() { } @@ -244,8 +244,7 @@ public CreateOrUpdateUserBody() { } if (PlexUsernames != null) { - var plexUsers = string.Join(',', PlexUsernames.Select(username => username.Trim()).Where(username => !string.IsNullOrEmpty(username))); - user.PlexUsers = string.IsNullOrWhiteSpace(plexUsers) ? null : plexUsers; + user.PlexUsers = string.IsNullOrWhiteSpace(PlexUsernames) ? null : PlexUsernames; } // Save the model now.