1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 01:37:07 +00:00

Fix: Growl will now work for notifying on grab/download.

Growl must be registered before notifications will work.
This commit is contained in:
Mark McDowall 2012-02-07 00:12:37 -08:00
parent 04fdb130b8
commit 7ae751371d
4 changed files with 52 additions and 3 deletions

View file

@ -33,7 +33,7 @@ namespace NzbDrone.Core.Providers.ExternalNotification
var host = growlHost[0]; var host = growlHost[0];
var port = Convert.ToInt32(growlHost[1]); var port = Convert.ToInt32(growlHost[1]);
_growlProvider.SendNotification(title, message, host, "GRAB", port, _configProvider.GrowlPassword); _growlProvider.SendNotification(title, message, "GRAB", host, port, _configProvider.GrowlPassword);
} }
} }
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Providers.ExternalNotification
var host = growlHost[0]; var host = growlHost[0];
var port = Convert.ToInt32(growlHost[1]); var port = Convert.ToInt32(growlHost[1]);
_growlProvider.SendNotification(title, message, host, "DOWNLOAD", port, _configProvider.GrowlPassword); _growlProvider.SendNotification(title, message, "DOWNLOAD", host, port, _configProvider.GrowlPassword);
} }
} }

View file

@ -4,6 +4,7 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.DownloadClients; using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Web.Filters; using NzbDrone.Web.Filters;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
using System;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {
@ -14,16 +15,18 @@ namespace NzbDrone.Web.Controllers
private readonly SmtpProvider _smtpProvider; private readonly SmtpProvider _smtpProvider;
private readonly TwitterProvider _twitterProvider; private readonly TwitterProvider _twitterProvider;
private readonly EpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly GrowlProvider _growlProvider;
public CommandController(JobProvider jobProvider, SabProvider sabProvider, public CommandController(JobProvider jobProvider, SabProvider sabProvider,
SmtpProvider smtpProvider, TwitterProvider twitterProvider, SmtpProvider smtpProvider, TwitterProvider twitterProvider,
EpisodeProvider episodeProvider) EpisodeProvider episodeProvider, GrowlProvider growlProvider)
{ {
_jobProvider = jobProvider; _jobProvider = jobProvider;
_sabProvider = sabProvider; _sabProvider = sabProvider;
_smtpProvider = smtpProvider; _smtpProvider = smtpProvider;
_twitterProvider = twitterProvider; _twitterProvider = twitterProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
_growlProvider = growlProvider;
} }
public JsonResult RssSync() public JsonResult RssSync()
@ -93,6 +96,25 @@ namespace NzbDrone.Web.Controllers
} }
public JsonResult RegisterGrowl(string host, string password)
{
try
{
var split = host.Split(':');
var hostname = split[0];
var port = Convert.ToInt32(split[1]);
_growlProvider.Register(hostname, port, password);
_growlProvider.TestNotification(hostname, port, password);
return JsonNotificationResult.Info("Good News!", "Registered and tested growl successfully");
}
catch(Exception ex)
{
return JsonNotificationResult.Opps("Couldn't register and test Growl");
}
}
[HttpPost] [HttpPost]
public EmptyResult SaveSeasonIgnore(int seriesId, int seasonNumber, bool ignored) public EmptyResult SaveSeasonIgnore(int seriesId, int seasonNumber, bool ignored)
{ {

View file

@ -30,4 +30,9 @@
<span class="small">@Html.DescriptionFor(m => m.GrowlPassword)</span> <span class="small">@Html.DescriptionFor(m => m.GrowlPassword)</span>
</label> </label>
@Html.TextBoxFor(m => m.GrowlPassword, new { @class = "inputClass", type = "password" }) @Html.TextBoxFor(m => m.GrowlPassword, new { @class = "inputClass", type = "password" })
<label class="labelClass">Register & Test
<span class="small">Register NzbDrone in Growl, must be done before notifications will work</span>
</label>
<input type="button" onclick="registerGrowl();" value="Register & Test" class="inputClass"/>
</div> </div>

View file

@ -123,5 +123,27 @@
return false; return false;
} }
//Growl
function registerGrowl() {
//Get the variables
var host = $('#GrowlHost').val();
var password = $('#GrowlPassword').val();
//Send the data!
$.ajax({
type: "POST",
url: '../Command/RegisterGrowl',
data: jQuery.param({
host: host,
password: password
}),
error: function (req, status, error) {
alert("Sorry! We could send a test email at this time. " + error);
}
});
return false;
}
</script> </script>
} }