diff --git a/data/interfaces/default/notification_config.html b/data/interfaces/default/notification_config.html
index ec384bcd..0267f478 100644
--- a/data/interfaces/default/notification_config.html
+++ b/data/interfaces/default/notification_config.html
@@ -66,6 +66,27 @@ from plexpy import helpers
% endfor
+
+
Test ${agent['name']}
+
Test if ${agent['name']} notifications are working. See logs for troubleshooting.
+
+
+
+
@@ -120,16 +141,21 @@ from plexpy import helpers
$.get("/twitterStep2", { 'key': twitter_key }, function (data) { $('#ajaxMsg').html(" " + data); });
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
});
- $('#testTwitter').click(function () {
- $.get("/testTwitter",
- function (data) { $('#ajaxMsg').html(" " + data); });
- $('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
- });
- $('#testIFTTT').click(function () {
- $.get("/test_ifttt",
- function (data) { $('#ajaxMsg').html(" " + data); });
- $('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
+ $('#test_notifier').click(function () {
+ doAjaxCall('set_notification_config', $(this), 'tabs', true);
+ $.ajax({
+ url: 'test_notifier',
+ data: { config_id: '${agent["id"]}',
+ subject: $('#test_subject').val(),
+ body: $('#test_body').val() },
+ cache: false,
+ async: true,
+ complete: function (xhr, status) {
+ msg = ' ' + xhr.responseText;
+ showMsg(msg, false, true, 2000);
+ }
+ });
});
$('#testSlack').click(function() {
diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py
index df024958..87cfaefa 100644
--- a/plexpy/notifiers.py
+++ b/plexpy/notifiers.py
@@ -1198,12 +1198,6 @@ class TwitterNotifier(object):
'description': 'Step 3: Verify the key.',
'input_type': 'button'
},
- {'label': 'Test Twitter',
- 'value': 'Test Twitter',
- 'name': 'testTwitter',
- 'description': 'Test if Twitter notifications are working. See logs for troubleshooting.',
- 'input_type': 'button'
- },
{'input_type': 'nosave'
}
]
@@ -1522,12 +1516,6 @@ class IFTTT(object):
'description': 'The Ifttt maker event to fire. The notification subject and body will be sent'
' as value1 and value2 respectively.',
'input_type': 'text'
- },
- {'label': 'Test Event',
- 'value': 'Test Event',
- 'name': 'testIFTTT',
- 'description': 'Test if IFTTT notifications are working. See logs for troubleshooting.',
- 'input_type': 'button'
}
]
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index f2bef4ae..a9eaae6c 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -659,6 +659,30 @@ class WebInterface(object):
return a.fetchData()
+ @cherrypy.expose
+ def test_notifier(self, config_id=None, subject='PlexPy', body='Test notification', **kwargs):
+ cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
+
+ if config_id.isdigit():
+ agents = notifiers.available_notification_agents()
+ for agent in agents:
+ if int(config_id) == agent['id']:
+ this_agent = agent
+ break
+ else:
+ this_agent = None
+
+ if this_agent:
+ logger.debug("Sending test %s notification." % this_agent['name'])
+ notifiers.send_notification(this_agent['id'], subject, body)
+ return "Notification sent."
+ else:
+ logger.debug("Unable to send test notification, invalid notification agent ID %s." % config_id)
+ return "Invalid notification agent ID %s." % config_id
+ else:
+ logger.debug("Unable to send test notification, no notification agent ID received.")
+ return "No notification agent ID received."
+
@cherrypy.expose
def twitterStep1(self):
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
@@ -676,37 +700,6 @@ class WebInterface(object):
else:
return "Unable to verify key"
- @cherrypy.expose
- def testTwitter(self):
- cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
- tweet = notifiers.TwitterNotifier()
- result = tweet.test_notify()
- if result:
- return "Tweet successful, check your twitter to make sure it worked"
- else:
- return "Error sending tweet"
-
- @cherrypy.expose
- def test_ifttt(self):
- cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
- event = notifiers.IFTTT()
- result = event.test()
- if result:
- return "Notification successful."
- else:
- return "Error sending event."
-
- @cherrypy.expose
- def test_slack(self):
- cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
- event = notifiers.SLACK()
- result = event.test()
-
- if result:
- return "Notification successful."
- else:
- return "Error sending event."
-
@cherrypy.expose
def osxnotifyregister(self, app):
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"