mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 19:50:15 -07:00
Fixed: New device_iden from PushBullet can be used
This commit is contained in:
parent
9b0114714d
commit
5ada7efefc
3 changed files with 26 additions and 8 deletions
|
@ -7,18 +7,18 @@ namespace NzbDrone.Core.Notifications.PushBullet
|
|||
{
|
||||
public interface IPushBulletProxy
|
||||
{
|
||||
void SendNotification(string title, string message, string apiKey, long deviceId);
|
||||
void SendNotification(string title, string message, string apiKey, string deviceId);
|
||||
}
|
||||
|
||||
public class PushBulletProxy : IPushBulletProxy, IExecute<TestPushBulletCommand>
|
||||
{
|
||||
private const string URL = "https://api.pushbullet.com/api/pushes";
|
||||
|
||||
public void SendNotification(string title, string message, string apiKey, long deviceId)
|
||||
public void SendNotification(string title, string message, string apiKey, string deviceId)
|
||||
{
|
||||
var client = new RestClient(URL);
|
||||
var request = new RestRequest(Method.POST);
|
||||
request.AddParameter("device_id", deviceId);
|
||||
var request = BuildRequest(deviceId);
|
||||
|
||||
request.AddParameter("type", "note");
|
||||
request.AddParameter("title", title);
|
||||
request.AddParameter("body", message);
|
||||
|
@ -27,6 +27,24 @@ namespace NzbDrone.Core.Notifications.PushBullet
|
|||
client.ExecuteAndValidate(request);
|
||||
}
|
||||
|
||||
public RestRequest BuildRequest(string deviceId)
|
||||
{
|
||||
var request = new RestRequest(Method.POST);
|
||||
long integerId;
|
||||
|
||||
if (Int64.TryParse(deviceId, out integerId))
|
||||
{
|
||||
request.AddParameter("device_id", integerId);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
request.AddParameter("device_iden", deviceId);
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public void Execute(TestPushBulletCommand message)
|
||||
{
|
||||
const string title = "Test Notification";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue