mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
#96 Finished adding test functionality to notifications
This commit is contained in:
parent
9742b42fdf
commit
3d41445f6f
3 changed files with 101 additions and 0 deletions
|
@ -145,9 +145,11 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
Get["/pushbulletnotification"] = _ => PushbulletNotifications();
|
Get["/pushbulletnotification"] = _ => PushbulletNotifications();
|
||||||
Post["/pushbulletnotification"] = _ => SavePushbulletNotifications();
|
Post["/pushbulletnotification"] = _ => SavePushbulletNotifications();
|
||||||
|
Post["/testpushbulletnotification"] = _ => TestPushbulletNotifications();
|
||||||
|
|
||||||
Get["/pushovernotification"] = _ => PushoverNotifications();
|
Get["/pushovernotification"] = _ => PushoverNotifications();
|
||||||
Post["/pushovernotification"] = _ => SavePushoverNotifications();
|
Post["/pushovernotification"] = _ => SavePushoverNotifications();
|
||||||
|
Post["/testpushovernotification"] = _ => TestPushoverNotifications();
|
||||||
|
|
||||||
Get["/logs"] = _ => Logs();
|
Get["/logs"] = _ => Logs();
|
||||||
Get["/loglevel"] = _ => GetLogLevels();
|
Get["/loglevel"] = _ => GetLogLevels();
|
||||||
|
@ -377,6 +379,11 @@ namespace PlexRequests.UI.Modules
|
||||||
private Response TestEmailNotifications()
|
private Response TestEmailNotifications()
|
||||||
{
|
{
|
||||||
var settings = this.Bind<EmailNotificationSettings>();
|
var settings = this.Bind<EmailNotificationSettings>();
|
||||||
|
var valid = this.Validate(settings);
|
||||||
|
if (!valid.IsValid)
|
||||||
|
{
|
||||||
|
return Response.AsJson(valid.SendJsonError());
|
||||||
|
}
|
||||||
var notificationModel = new NotificationModel
|
var notificationModel = new NotificationModel
|
||||||
{
|
{
|
||||||
NotificationType = NotificationType.Test,
|
NotificationType = NotificationType.Test,
|
||||||
|
@ -455,6 +462,24 @@ namespace PlexRequests.UI.Modules
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response TestPushbulletNotifications()
|
||||||
|
{
|
||||||
|
var settings = this.Bind<PushbulletNotificationSettings>();
|
||||||
|
var valid = this.Validate(settings);
|
||||||
|
if (!valid.IsValid)
|
||||||
|
{
|
||||||
|
return Response.AsJson(valid.SendJsonError());
|
||||||
|
}
|
||||||
|
var notificationModel = new NotificationModel
|
||||||
|
{
|
||||||
|
NotificationType = NotificationType.Test,
|
||||||
|
DateTime = DateTime.Now
|
||||||
|
};
|
||||||
|
NotificationService.Publish(notificationModel, settings);
|
||||||
|
Log.Info("Sent pushbullet notification test");
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Pushbullet Notification!" });
|
||||||
|
}
|
||||||
|
|
||||||
private Negotiator PushoverNotifications()
|
private Negotiator PushoverNotifications()
|
||||||
{
|
{
|
||||||
var settings = PushoverService.GetSettings();
|
var settings = PushoverService.GetSettings();
|
||||||
|
@ -487,6 +512,24 @@ namespace PlexRequests.UI.Modules
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response TestPushoverNotifications()
|
||||||
|
{
|
||||||
|
var settings = this.Bind<PushoverNotificationSettings>();
|
||||||
|
var valid = this.Validate(settings);
|
||||||
|
if (!valid.IsValid)
|
||||||
|
{
|
||||||
|
return Response.AsJson(valid.SendJsonError());
|
||||||
|
}
|
||||||
|
var notificationModel = new NotificationModel
|
||||||
|
{
|
||||||
|
NotificationType = NotificationType.Test,
|
||||||
|
DateTime = DateTime.Now
|
||||||
|
};
|
||||||
|
NotificationService.Publish(notificationModel, settings);
|
||||||
|
Log.Info("Sent pushover notification test");
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Pushover Notification!" });
|
||||||
|
}
|
||||||
|
|
||||||
private Response GetCpProfiles()
|
private Response GetCpProfiles()
|
||||||
{
|
{
|
||||||
var settings = this.Bind<CouchPotatoSettings>();
|
var settings = this.Bind<CouchPotatoSettings>();
|
||||||
|
|
|
@ -36,6 +36,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button id="testPushbullet" type="submit" class="btn btn-primary-outline">Test</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
||||||
|
@ -70,5 +76,28 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#testPushbullet').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: '/admin/testpushbulletnotification',
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
|
@ -36,6 +36,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button id="testPushover" type="submit" class="btn btn-primary-outline">Test</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
||||||
|
@ -70,5 +76,28 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#testPushover').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: '/admin/testpushovernotification',
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue