Skip to content

Commit

Permalink
Fixed #74 and #64
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Mar 22, 2016
1 parent 206fd74 commit da8b634
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 0 additions & 3 deletions PlexRequests.Services/Notification/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ public static void Publish(string title, string requester)

public static void Subscribe(INotification notification)
{
Log.Trace("Subscribing Observer {0}", notification.NotificationName);
INotification notificationValue;
if (Observers.TryGetValue(notification.NotificationName, out notificationValue))
{
Log.Trace("Observer {0} already exists", notification.NotificationName);
// Observer already exists
return;
}

Expand Down
21 changes: 17 additions & 4 deletions PlexRequests.UI/Modules/AdminModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,15 @@ private Response SaveEmailNotifications()
Log.Trace(settings.DumpJson());

var result = EmailService.SaveSettings(settings);

NotificationService.Subscribe(new EmailMessageNotification(EmailService));

if (settings.Enabled)
{
NotificationService.Subscribe(new EmailMessageNotification(EmailService));
}
else
{
NotificationService.UnSubscribe(new EmailMessageNotification(EmailService));
}

Log.Info("Saved email settings, result: {0}", result);
return Response.AsJson(result
Expand Down Expand Up @@ -389,8 +396,14 @@ private Response SavePushbulletNotifications()
Log.Trace(settings.DumpJson());

var result = PushbulletService.SaveSettings(settings);

NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService));
if (settings.Enabled)
{
NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService));
}
else
{
NotificationService.UnSubscribe(new PushbulletNotification(PushbulletApi, PushbulletService));
}

Log.Info("Saved email settings, result: {0}", result);
return Response.AsJson(result
Expand Down

0 comments on commit da8b634

Please sign in to comment.