Merge branch 'develop' into feature/lidarr

pull/2473/head
Jamie 6 years ago committed by GitHub
commit 8fd3c57cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,6 @@ namespace Ombi.Api.Pushover
{
public interface IPushoverApi
{
Task<PushoverResponse> PushAsync(string accessToken, string message, string userToken);
Task<PushoverResponse> PushAsync(string accessToken, string message, string userToken, sbyte priority, string sound);
}
}

@ -16,13 +16,13 @@ namespace Ombi.Api.Pushover
private readonly IApi _api;
private const string PushoverEndpoint = "https://api.pushover.net/1";
public async Task<PushoverResponse> PushAsync(string accessToken, string message, string userToken)
public async Task<PushoverResponse> PushAsync(string accessToken, string message, string userToken, sbyte priority, string sound)
{
if (message.Contains("'"))
{
message = message.Replace("'", "&#39;");
}
var request = new Request($"messages.json?token={accessToken}&user={userToken}&message={WebUtility.HtmlEncode(message)}", PushoverEndpoint, HttpMethod.Post);
var request = new Request($"messages.json?token={accessToken}&user={userToken}&priority={priority}&sound={sound}&message={WebUtility.HtmlEncode(message)}", PushoverEndpoint, HttpMethod.Post);
var result = await _api.Request<PushoverResponse>(request);
return result;

@ -5,10 +5,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.7.99" />
<PackageReference Include="Nunit" Version="3.8.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="Nunit" Version="3.10.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.8.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<packagereference Include="Microsoft.NET.Test.Sdk" Version="15.8.0"></packagereference>
</ItemGroup>

@ -0,0 +1,26 @@
using System.Collections.Generic;
using NUnit.Framework;
using Ombi.Helpers;
namespace Ombi.Core.Tests
{
[TestFixture]
public class StringHelperTests
{
[TestCaseSource(nameof(StripCharsData))]
public string StripCharacters(string str, char[] chars)
{
return str.StripCharacters(chars);
}
private static IEnumerable<TestCaseData> StripCharsData
{
get
{
yield return new TestCaseData("this!is^a*string",new []{'!','^','*'}).Returns("thisisastring").SetName("Basic Strip Multipe Chars");
yield return new TestCaseData("What is this madness'",new []{'\'','^','*'}).Returns("What is this madness").SetName("Basic Strip Multipe Chars");
}
}
}
}

@ -80,5 +80,9 @@ namespace Ombi.Helpers
{
return str.Replace(" ", "");
}
public static string StripCharacters(this string str, params char[] chars)
{
return string.Concat(str.Where(c => !chars.Contains(c)));
}
}
}

@ -177,7 +177,8 @@ namespace Ombi.Notifications.Agents
{
try
{
await Api.PushAsync(settings.AccessToken, model.Message, settings.UserToken);
//&+' < >
await Api.PushAsync(settings.AccessToken, model.Message.StripCharacters('&','+','<','>'), settings.UserToken, settings.Priority, settings.Sound);
}
catch (Exception e)
{

@ -8,5 +8,7 @@ namespace Ombi.Settings.Settings.Models.Notifications
public bool Enabled { get; set; }
public string AccessToken { get; set; }
public string UserToken { get; set; }
public sbyte Priority { get; set; } = 0;
public string Sound { get; set; } = "pushover";
}
}

@ -88,6 +88,8 @@ export interface IPushoverNotificationSettings extends INotificationSettings {
accessToken: string;
notificationTemplates: INotificationTemplates[];
userToken: string;
priority: number;
sound: string;
}
export interface IMattermostNotifcationSettings extends INotificationSettings {

@ -28,6 +28,48 @@
</div>
</div>
<div class="form-group">
<label for="priority" class="control-label">Priority</label>
<div>
<select class="form-control form-control-custom " id="priority" name="priority" formControlName="priority" pTooltip="The priority you want your pushover notifications sent as.">
<option value="0">Normal</option>
<option value="1">High</option>
<option value="-1">Low</option>
<option value="-2">Lowest</option>
</select>
</div>
</div>
<div class="form-group">
<label for="sound" class="control-label">Sound</label>
<div>
<select class="form-control form-control-custom " id="sound" name="sound" formControlName="sound" pTooltip="The sound you want your pushover notifications sent with.">
<option value="pushover">Pushover</option>
<option value="bike">Bike</option>
<option value="bugle">Bugle</option>
<option value="cashregister">Cash Register</option>
<option value="classical">Classical</option>
<option value="cosmic">Cosmic</option>
<option value="falling">Falling</option>
<option value="gamelan">Gamelan</option>
<option value="incoming">Incoming</option>
<option value="intermission">Intermission</option>
<option value="magic">Magic</option>
<option value="mechanical">Mechanical</option>
<option value="pianobar">Piano Bar</option>
<option value="siren">Siren</option>
<option value="spacealarm">Space Alarm</option>
<option value="tugboat">Tug Boat</option>
<option value="alien">Alien Alarm (long)</option>
<option value="climb">Climb (long)</option>
<option value="persistent">Persistent (long)</option>
<option value="echo">Pushover Echo (long)</option>
<option value="updown">Up Down (long)</option>
<option value="none">None</option>
</select>
</div>
</div>
<div class="form-group">

@ -27,6 +27,8 @@ export class PushoverComponent implements OnInit {
enabled: [x.enabled],
userToken: [x.userToken],
accessToken: [x.accessToken, [Validators.required]],
priority: [x.priority],
sound: [x.sound],
});
});
}

Loading…
Cancel
Save