This commit is contained in:
Jamie.Rees 2017-02-01 08:27:16 +00:00
parent d050fa129f
commit a206141f98
3 changed files with 46 additions and 12 deletions

View file

@ -171,8 +171,9 @@ namespace Ombi.Services.Notification
try
{
var settings = await PlexSettings.GetSettingsAsync();
var plexUser = PlexApi.GetUsers(settings.PlexAuthToken);
var plexUser = PlexApi.GetUsers(settings.PlexAuthToken); // TODO emby
var userAccount = PlexApi.GetAccount(settings.PlexAuthToken);
var localUsers = UserHelper.GetUsers().ToList();
var adminUsername = userAccount.Username ?? string.Empty;
@ -219,11 +220,17 @@ namespace Ombi.Services.Notification
}
var email = plexUser.User.FirstOrDefault(x => x.Username.Equals(user, StringComparison.CurrentCultureIgnoreCase));
if (email == null)
if (email == null) // This is not a Plex User
{
Log.Info("There is no email address for this Plex user, cannot send notification");
// We do not have a plex user that requested this!
continue;
// Local User?
var local = localUsers.FirstOrDefault(x => x.UsernameOrAlias.Equals(user));
if (local != null)
{
Log.Info("Sending notification to: {0} at: {1}, for title: {2}", local.UsernameOrAlias, local.EmailAddress, model.Title);
await PublishUserNotification(local.UsernameOrAlias, local.EmailAddress, model.Title, model.PosterPath, type, model.Type);
continue;
}
}
Log.Info("Sending notification to: {0} at: {1}, for title: {2}", email.Username, email.Email, model.Title);