Skip to content

Commit

Permalink
API v3 User DTO: expose PlexUsernames as comma-separated string ins…
Browse files Browse the repository at this point in the history
…tead of `List`
  • Loading branch information
harshithmohan committed Sep 13, 2024
1 parent ccfa60c commit eafdce5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Shoko.Server/API/v3/Models/Shoko/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class User
/// <summary>
/// The user's Plex usernames.
/// </summary>
public List<string> PlexUsernames { get; set; }
public string PlexUsernames { get; set; }

public User(SVR_JMMUser user)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -149,7 +149,7 @@ public class CreateOrUpdateUserBody
/// <summary>
/// The new user's Plex usernames.
/// </summary>
public List<string>? PlexUsernames { get; set; }
public string? PlexUsernames { get; set; }

public CreateOrUpdateUserBody() { }

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit eafdce5

Please sign in to comment.