Skip to content

Commit

Permalink
fix(user-importer): Fixed not importing all correct users #4989
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Jul 28, 2023
1 parent 880e511 commit 34c32f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/Ombi.Api.Plex/Models/Friends/PlexFriends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class UserFriends
public string Username { get; set; }
[XmlAttribute(AttributeName = "email")]
public string Email { get; set; }
/// <summary>
/// DO NOT USE THIS
/// Home Users can actually be an unmanaged account with an email/username to log in.
/// </summary>
[XmlAttribute(AttributeName = "home")]
public bool HomeUser { get; set; }
}
Expand Down
3 changes: 1 addition & 2 deletions src/Ombi.Api.Plex/PlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ private string ApplicationName
}

private const string SignInUri = "https://plex.tv/users/sign_in.json";
private const string NewFriendsUri = "https://plex.tv/api/users";
private const string FriendsUri = "https://plex.tv/pms/friends/all";
private const string FriendsUri = "https://plex.tv/api/users";
private const string GetAccountUri = "https://plex.tv/users/account.json";
private const string ServerUri = "https://plex.tv/pms/servers.xml";
private const string WatchlistUri = "https://metadata.provider.plex.tv/";
Expand Down
9 changes: 2 additions & 7 deletions src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,14 @@ private async Task<List<OmbiUser>> ImportPlexUsers(UserManagementSettings userMa
continue;
}

if (plexUser.HomeUser)
{
_log.LogInformation($"User '{plexUser.Title}' is a Plex Home User. Home Users are not supported");
continue;
}

// Check if this Plex User already exists
// We are using the Plex USERNAME and Not the TITLE, the Title is for HOME USERS without an account
var existingPlexUser = allUsers.FirstOrDefault(x => x.ProviderUserId == plexUser.Id);
if (existingPlexUser == null)
{
if (!plexUser.Username.HasValue())
{
_log.LogInformation($"Could not create Plex user since the have no username, PlexUserId: {plexUser.Id}");
_log.LogInformation($"Could not create user since the have no username (Probably a Home User), PlexUserId: {plexUser.Id}, Title: {plexUser.Title}");
continue;
}

Expand Down

0 comments on commit 34c32f8

Please sign in to comment.