From f64ccd73272f44cee9fb2ac08f5a9f47cefdb4b9 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 22 Mar 2016 21:31:52 +0000 Subject: [PATCH] Resolved #75 --- .../Notification/PushbulletNotification.cs | 14 +++++++++++--- PlexRequests.UI/Modules/RequestsModule.cs | 13 +++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/PlexRequests.Services/Notification/PushbulletNotification.cs b/PlexRequests.Services/Notification/PushbulletNotification.cs index be6af1ef2..20c4b9f35 100644 --- a/PlexRequests.Services/Notification/PushbulletNotification.cs +++ b/PlexRequests.Services/Notification/PushbulletNotification.cs @@ -77,7 +77,15 @@ namespace PlexRequests.Services.Notification private bool ValidateConfiguration() { - return !Settings.Enabled && !string.IsNullOrEmpty(Settings.AccessToken); + if (!Settings.Enabled) + { + return false; + } + if (string.IsNullOrEmpty(Settings.AccessToken)) + { + return false; + } + return true; } private PushbulletNotificationSettings GetSettings() @@ -106,8 +114,8 @@ namespace PlexRequests.Services.Notification private bool PushIssue(NotificationModel model) { - var message = $"A new issue: {model.Title} has been reported by user: {model.User} for the title: {model.Body}"; - var pushTitle = $"Plex Requests: A new issue has been reported for {model.Body}"; + var message = $"A new issue: {model.Body} has been reported by user: {model.User} for the title: {model.Title}"; + var pushTitle = $"Plex Requests: A new issue has been reported for {model.Title}"; try { var result = PushbulletApi.Push(Settings.AccessToken, pushTitle, message, Settings.DeviceIdentifier); diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs index 4f534e0b9..228a0d752 100644 --- a/PlexRequests.UI/Modules/RequestsModule.cs +++ b/PlexRequests.UI/Modules/RequestsModule.cs @@ -25,6 +25,7 @@ // ************************************************************************/ #endregion +using System; using System.Collections.Generic; using System.Linq; @@ -37,6 +38,7 @@ using Nancy.Security; using PlexRequests.Api; using PlexRequests.Core; using PlexRequests.Core.SettingModels; +using PlexRequests.Services.Notification; using PlexRequests.Store; using PlexRequests.UI.Models; @@ -166,6 +168,17 @@ namespace PlexRequests.UI.Modules var result = Service.UpdateRequest(originalRequest); + + var model = new NotificationModel + { + User = Session[SessionKeys.UsernameKey].ToString(), + NotificationType = NotificationType.Issue, + Title = originalRequest.Title, + DateTime = DateTime.Now, + Body = issue == IssueState.Other ? comment : issue.Humanize() + }; + NotificationService.Publish(model); + return Response.AsJson(result ? new JsonResponseModel { Result = true } : new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });