mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
Fixed #1036
This commit is contained in:
parent
d050fa129f
commit
a206141f98
3 changed files with 46 additions and 12 deletions
|
@ -130,6 +130,7 @@ namespace Ombi.Services.Notification
|
||||||
var embySettings = await EmbySettings.GetSettingsAsync();
|
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||||
var embyUsers = EmbyApi.GetUsers(embySettings.FullUri, embySettings.ApiKey);
|
var embyUsers = EmbyApi.GetUsers(embySettings.FullUri, embySettings.ApiKey);
|
||||||
var userAccount = embyUsers.FirstOrDefault(x => x.Policy.IsAdministrator);
|
var userAccount = embyUsers.FirstOrDefault(x => x.Policy.IsAdministrator);
|
||||||
|
var localUsers = UserHelper.GetUsers().ToList();
|
||||||
|
|
||||||
var adminUsername = userAccount.Name ?? string.Empty;
|
var adminUsername = userAccount.Name ?? string.Empty;
|
||||||
|
|
||||||
|
@ -179,9 +180,15 @@ namespace Ombi.Services.Notification
|
||||||
var email = embyUsers.FirstOrDefault(x => x.Name.Equals(user, StringComparison.CurrentCultureIgnoreCase));
|
var email = embyUsers.FirstOrDefault(x => x.Name.Equals(user, StringComparison.CurrentCultureIgnoreCase));
|
||||||
if (email == null)
|
if (email == null)
|
||||||
{
|
{
|
||||||
Log.Info("There is no email address for this Emby user, cannot send notification");
|
// Local User?
|
||||||
// We do not have a emby user that requested this!
|
var local = localUsers.FirstOrDefault(x => x.UsernameOrAlias.Equals(user));
|
||||||
continue;
|
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.Name, embyUser.EmailAddress, model.Title);
|
Log.Info("Sending notification to: {0} at: {1}, for title: {2}", email.Name, embyUser.EmailAddress, model.Title);
|
||||||
|
|
|
@ -171,8 +171,9 @@ namespace Ombi.Services.Notification
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var settings = await PlexSettings.GetSettingsAsync();
|
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 userAccount = PlexApi.GetAccount(settings.PlexAuthToken);
|
||||||
|
var localUsers = UserHelper.GetUsers().ToList();
|
||||||
|
|
||||||
var adminUsername = userAccount.Username ?? string.Empty;
|
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));
|
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");
|
// Local User?
|
||||||
// We do not have a plex user that requested this!
|
var local = localUsers.FirstOrDefault(x => x.UsernameOrAlias.Equals(user));
|
||||||
continue;
|
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);
|
Log.Info("Sending notification to: {0} at: {1}, for title: {2}", email.Username, email.Email, model.Title);
|
||||||
|
|
|
@ -66,8 +66,10 @@ namespace Ombi.UI.Modules
|
||||||
ICacheProvider cache,
|
ICacheProvider cache,
|
||||||
IAnalytics an,
|
IAnalytics an,
|
||||||
IPlexNotificationEngine engine,
|
IPlexNotificationEngine engine,
|
||||||
|
IEmbyNotificationEngine embyEngine,
|
||||||
ISecurityExtensions security,
|
ISecurityExtensions security,
|
||||||
ISettingsService<CustomizationSettings> customSettings) : base("requests", prSettings, security)
|
ISettingsService<CustomizationSettings> customSettings,
|
||||||
|
ISettingsService<EmbySettings> embyS) : base("requests", prSettings, security)
|
||||||
{
|
{
|
||||||
Service = service;
|
Service = service;
|
||||||
PrSettings = prSettings;
|
PrSettings = prSettings;
|
||||||
|
@ -81,8 +83,10 @@ namespace Ombi.UI.Modules
|
||||||
CpApi = cpApi;
|
CpApi = cpApi;
|
||||||
Cache = cache;
|
Cache = cache;
|
||||||
Analytics = an;
|
Analytics = an;
|
||||||
NotificationEngine = engine;
|
PlexNotificationEngine = engine;
|
||||||
|
EmbyNotificationEngine = embyEngine;
|
||||||
CustomizationSettings = customSettings;
|
CustomizationSettings = customSettings;
|
||||||
|
EmbySettings = embyS;
|
||||||
|
|
||||||
Get["/", true] = async (x, ct) => await LoadRequests();
|
Get["/", true] = async (x, ct) => await LoadRequests();
|
||||||
Get["/movies", true] = async (x, ct) => await GetMovies();
|
Get["/movies", true] = async (x, ct) => await GetMovies();
|
||||||
|
@ -111,11 +115,13 @@ namespace Ombi.UI.Modules
|
||||||
private ISettingsService<SickRageSettings> SickRageSettings { get; }
|
private ISettingsService<SickRageSettings> SickRageSettings { get; }
|
||||||
private ISettingsService<CouchPotatoSettings> CpSettings { get; }
|
private ISettingsService<CouchPotatoSettings> CpSettings { get; }
|
||||||
private ISettingsService<CustomizationSettings> CustomizationSettings { get; }
|
private ISettingsService<CustomizationSettings> CustomizationSettings { get; }
|
||||||
|
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SickRageApi { get; }
|
private ISickRageApi SickRageApi { get; }
|
||||||
private ICouchPotatoApi CpApi { get; }
|
private ICouchPotatoApi CpApi { get; }
|
||||||
private ICacheProvider Cache { get; }
|
private ICacheProvider Cache { get; }
|
||||||
private INotificationEngine NotificationEngine { get; }
|
private INotificationEngine PlexNotificationEngine { get; }
|
||||||
|
private INotificationEngine EmbyNotificationEngine { get; }
|
||||||
|
|
||||||
private async Task<Negotiator> LoadRequests()
|
private async Task<Negotiator> LoadRequests()
|
||||||
{
|
{
|
||||||
|
@ -438,7 +444,21 @@ namespace Ombi.UI.Modules
|
||||||
originalRequest.Available = available;
|
originalRequest.Available = available;
|
||||||
|
|
||||||
var result = await Service.UpdateRequestAsync(originalRequest);
|
var result = await Service.UpdateRequestAsync(originalRequest);
|
||||||
await NotificationEngine.NotifyUsers(originalRequest, available ? NotificationType.RequestAvailable : NotificationType.RequestDeclined);
|
|
||||||
|
var plexSettings = await PlexSettings.GetSettingsAsync();
|
||||||
|
if (plexSettings.Enable)
|
||||||
|
{
|
||||||
|
await
|
||||||
|
PlexNotificationEngine.NotifyUsers(originalRequest,
|
||||||
|
available ? NotificationType.RequestAvailable : NotificationType.RequestDeclined);
|
||||||
|
}
|
||||||
|
|
||||||
|
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||||
|
if (embySettings.Enable)
|
||||||
|
{
|
||||||
|
await EmbyNotificationEngine.NotifyUsers(originalRequest,
|
||||||
|
available ? NotificationType.RequestAvailable : NotificationType.RequestDeclined);
|
||||||
|
}
|
||||||
return Response.AsJson(result
|
return Response.AsJson(result
|
||||||
? new { Result = true, Available = available, Message = string.Empty }
|
? new { Result = true, Available = available, Message = string.Empty }
|
||||||
: new { Result = false, Available = false, Message = "Could not update the availability, please try again or check the logs" });
|
: new { Result = false, Available = false, Message = "Could not update the availability, please try again or check the logs" });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue