|
|
|
@ -16,11 +16,13 @@ namespace NzbDrone.Core.Notifications.Join
|
|
|
|
|
|
|
|
|
|
public class JoinProxy : IJoinProxy
|
|
|
|
|
{
|
|
|
|
|
private readonly IRestClientFactory _restClientFactory;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
private const string URL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?";
|
|
|
|
|
|
|
|
|
|
public JoinProxy(Logger logger)
|
|
|
|
|
public JoinProxy(IRestClientFactory restClientFactory, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_restClientFactory = restClientFactory;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -49,7 +51,7 @@ namespace NzbDrone.Core.Notifications.Join
|
|
|
|
|
SendNotification(title, body, settings);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch(JoinInvalidDeviceException ex)
|
|
|
|
|
catch (JoinInvalidDeviceException ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error(ex, "Unable to send test Join message. Invalid Device IDs supplied.");
|
|
|
|
|
return new ValidationFailure("DeviceIds", "Device IDs appear invalid.");
|
|
|
|
@ -59,7 +61,7 @@ namespace NzbDrone.Core.Notifications.Join
|
|
|
|
|
_logger.Error(ex, "Unable to send test Join message.");
|
|
|
|
|
return new ValidationFailure("ApiKey", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
catch(RestException ex)
|
|
|
|
|
catch (RestException ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error(ex, "Unable to send test Join message. Server connection failed.");
|
|
|
|
|
return new ValidationFailure("ApiKey", "Unable to connect to Join API. Please try again later.");
|
|
|
|
@ -74,7 +76,7 @@ namespace NzbDrone.Core.Notifications.Join
|
|
|
|
|
private void SendNotification(string title, string message, RestRequest request, JoinSettings settings)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var client = RestClientFactory.BuildClient(URL);
|
|
|
|
|
var client = _restClientFactory.BuildClient(URL);
|
|
|
|
|
|
|
|
|
|
if (settings.DeviceNames.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
@ -88,7 +90,7 @@ namespace NzbDrone.Core.Notifications.Join
|
|
|
|
|
{
|
|
|
|
|
request.AddParameter("deviceId", "group.all");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
request.AddParameter("apikey", settings.ApiKey);
|
|
|
|
|
request.AddParameter("title", title);
|
|
|
|
|
request.AddParameter("text", message);
|
|
|
|
|