Allow for the ability to set Pushover notification sound and priority from within Ombi.

pull/2468/head
David Pooley 6 years ago
parent 94a1f3a00d
commit c6bb864be7

@ -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;

@ -177,7 +177,7 @@ namespace Ombi.Notifications.Agents
{
try
{
await Api.PushAsync(settings.AccessToken, model.Message, settings.UserToken);
await Api.PushAsync(settings.AccessToken, model.Message, 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; }
public string Sound { get; set; }
}
}

@ -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