mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 07:46:07 -07:00
Return success/failed message for testing notifications
This commit is contained in:
parent
698275633f
commit
ff532a5c6c
3 changed files with 46 additions and 29 deletions
|
@ -190,7 +190,10 @@ from plexpy import helpers
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#test_notifier').click(function () {
|
$('#test_notifier').click(function () {
|
||||||
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
doAjaxCall('set_notification_config', $(this), 'tabs', true, sendTestNotification);
|
||||||
|
});
|
||||||
|
|
||||||
|
function sendTestNotification() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'test_notifier',
|
url: 'test_notifier',
|
||||||
data: {
|
data: {
|
||||||
|
@ -203,11 +206,16 @@ from plexpy import helpers
|
||||||
cache: false,
|
cache: false,
|
||||||
async: true,
|
async: true,
|
||||||
complete: function (xhr, status) {
|
complete: function (xhr, status) {
|
||||||
msg = '<i class="fa fa-check"></i> ' + xhr.responseText;
|
if (xhr.responseText.indexOf('sent') > -1) {
|
||||||
showMsg(msg, false, true, 2000);
|
msg = '<i class="fa fa-check"></i> ' + xhr.responseText;
|
||||||
|
showMsg(msg, false, true, 2000);
|
||||||
|
} else {
|
||||||
|
msg = '<i class="fa fa-times"></i> ' + xhr.responseText;
|
||||||
|
showMsg(msg, false, true, 2000, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
$('#pushbullet_apikey, #pushover_apitoken, #scripts_folder').on('change', function () {
|
$('#pushbullet_apikey, #pushover_apitoken, #scripts_folder').on('change', function () {
|
||||||
// Reload modal to update certain fields
|
// Reload modal to update certain fields
|
||||||
|
|
|
@ -445,55 +445,55 @@ def send_notification(agent_id, subject, body, notify_action, **kwargs):
|
||||||
|
|
||||||
if agent_id == 0:
|
if agent_id == 0:
|
||||||
growl = GROWL()
|
growl = GROWL()
|
||||||
growl.notify(message=body, event=subject)
|
return growl.notify(message=body, event=subject)
|
||||||
elif agent_id == 1:
|
elif agent_id == 1:
|
||||||
prowl = PROWL()
|
prowl = PROWL()
|
||||||
prowl.notify(message=body, event=subject)
|
return prowl.notify(message=body, event=subject)
|
||||||
elif agent_id == 2:
|
elif agent_id == 2:
|
||||||
xbmc = XBMC()
|
xbmc = XBMC()
|
||||||
xbmc.notify(subject=subject, message=body)
|
return xbmc.notify(subject=subject, message=body)
|
||||||
elif agent_id == 3:
|
elif agent_id == 3:
|
||||||
plex = Plex()
|
plex = Plex()
|
||||||
plex.notify(subject=subject, message=body)
|
return plex.notify(subject=subject, message=body)
|
||||||
elif agent_id == 4:
|
elif agent_id == 4:
|
||||||
nma = NMA()
|
nma = NMA()
|
||||||
nma.notify(subject=subject, message=body)
|
return nma.notify(subject=subject, message=body)
|
||||||
elif agent_id == 5:
|
elif agent_id == 5:
|
||||||
pushalot = PUSHALOT()
|
pushalot = PUSHALOT()
|
||||||
pushalot.notify(message=body, event=subject)
|
return pushalot.notify(message=body, event=subject)
|
||||||
elif agent_id == 6:
|
elif agent_id == 6:
|
||||||
pushbullet = PUSHBULLET()
|
pushbullet = PUSHBULLET()
|
||||||
pushbullet.notify(message=body, subject=subject)
|
return pushbullet.notify(message=body, subject=subject)
|
||||||
elif agent_id == 7:
|
elif agent_id == 7:
|
||||||
pushover = PUSHOVER()
|
pushover = PUSHOVER()
|
||||||
pushover.notify(message=body, event=subject)
|
return pushover.notify(message=body, event=subject)
|
||||||
elif agent_id == 8:
|
elif agent_id == 8:
|
||||||
osx_notify = OSX_NOTIFY()
|
osx_notify = OSX_NOTIFY()
|
||||||
osx_notify.notify(title=subject, text=body)
|
return osx_notify.notify(title=subject, text=body)
|
||||||
elif agent_id == 9:
|
elif agent_id == 9:
|
||||||
boxcar = BOXCAR()
|
boxcar = BOXCAR()
|
||||||
boxcar.notify(title=subject, message=body)
|
return boxcar.notify(title=subject, message=body)
|
||||||
elif agent_id == 10:
|
elif agent_id == 10:
|
||||||
email = Email()
|
email = Email()
|
||||||
email.notify(subject=subject, message=body)
|
return email.notify(subject=subject, message=body)
|
||||||
elif agent_id == 11:
|
elif agent_id == 11:
|
||||||
tweet = TwitterNotifier()
|
tweet = TwitterNotifier()
|
||||||
tweet.notify(subject=subject, message=body)
|
return tweet.notify(subject=subject, message=body)
|
||||||
elif agent_id == 12:
|
elif agent_id == 12:
|
||||||
iftttClient = IFTTT()
|
iftttClient = IFTTT()
|
||||||
iftttClient.notify(subject=subject, message=body, action=notify_action)
|
return iftttClient.notify(subject=subject, message=body, action=notify_action)
|
||||||
elif agent_id == 13:
|
elif agent_id == 13:
|
||||||
telegramClient = TELEGRAM()
|
telegramClient = TELEGRAM()
|
||||||
telegramClient.notify(message=body, event=subject, **kwargs)
|
return telegramClient.notify(message=body, event=subject, **kwargs)
|
||||||
elif agent_id == 14:
|
elif agent_id == 14:
|
||||||
slackClient = SLACK()
|
slackClient = SLACK()
|
||||||
slackClient.notify(message=body, event=subject)
|
return slackClient.notify(message=body, event=subject)
|
||||||
elif agent_id == 15:
|
elif agent_id == 15:
|
||||||
scripts = Scripts()
|
scripts = Scripts()
|
||||||
scripts.notify(message=body, subject=subject, notify_action=notify_action, **kwargs)
|
return scripts.notify(message=body, subject=subject, notify_action=notify_action, **kwargs)
|
||||||
elif agent_id == 16:
|
elif agent_id == 16:
|
||||||
facebook = FacebookNotifier()
|
facebook = FacebookNotifier()
|
||||||
facebook.notify(subject=subject, message=body, **kwargs)
|
return facebook.notify(subject=subject, message=body, **kwargs)
|
||||||
else:
|
else:
|
||||||
logger.debug(u"PlexPy Notifiers :: Unknown agent id received.")
|
logger.debug(u"PlexPy Notifiers :: Unknown agent id received.")
|
||||||
else:
|
else:
|
||||||
|
@ -546,10 +546,10 @@ class GROWL(object):
|
||||||
growl.register()
|
growl.register()
|
||||||
except gntp.notifier.errors.NetworkError:
|
except gntp.notifier.errors.NetworkError:
|
||||||
logger.warn(u"PlexPy Notifiers :: Growl notification failed: network error")
|
logger.warn(u"PlexPy Notifiers :: Growl notification failed: network error")
|
||||||
return
|
return False
|
||||||
except gntp.notifier.errors.AuthError:
|
except gntp.notifier.errors.AuthError:
|
||||||
logger.warn(u"PlexPy Notifiers :: Growl notification failed: authentication error")
|
logger.warn(u"PlexPy Notifiers :: Growl notification failed: authentication error")
|
||||||
return
|
return False
|
||||||
|
|
||||||
# Fix message
|
# Fix message
|
||||||
message = message.encode(plexpy.SYS_ENCODING, "replace")
|
message = message.encode(plexpy.SYS_ENCODING, "replace")
|
||||||
|
@ -569,9 +569,10 @@ class GROWL(object):
|
||||||
icon=image
|
icon=image
|
||||||
)
|
)
|
||||||
logger.info(u"PlexPy Notifiers :: Growl notification sent.")
|
logger.info(u"PlexPy Notifiers :: Growl notification sent.")
|
||||||
|
return True
|
||||||
except gntp.notifier.errors.NetworkError:
|
except gntp.notifier.errors.NetworkError:
|
||||||
logger.warn(u"PlexPy Notifiers :: Growl notification failed: network error")
|
logger.warn(u"PlexPy Notifiers :: Growl notification failed: network error")
|
||||||
return
|
return False
|
||||||
|
|
||||||
|
|
||||||
def updateLibrary(self):
|
def updateLibrary(self):
|
||||||
|
@ -734,9 +735,11 @@ class XBMC(object):
|
||||||
raise Exception
|
raise Exception
|
||||||
else:
|
else:
|
||||||
logger.info(u"PlexPy Notifiers :: XBMC notification sent.")
|
logger.info(u"PlexPy Notifiers :: XBMC notification sent.")
|
||||||
|
return True
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warn(u"PlexPy Notifiers :: XBMC notification filed.")
|
logger.warn(u"PlexPy Notifiers :: XBMC notification filed.")
|
||||||
|
return False
|
||||||
|
|
||||||
def return_config_options(self):
|
def return_config_options(self):
|
||||||
config_option = [{'label': 'XBMC Host:Port',
|
config_option = [{'label': 'XBMC Host:Port',
|
||||||
|
@ -816,9 +819,11 @@ class Plex(object):
|
||||||
raise Exception
|
raise Exception
|
||||||
else:
|
else:
|
||||||
logger.info(u"PlexPy Notifiers :: Plex Home Theater notification sent.")
|
logger.info(u"PlexPy Notifiers :: Plex Home Theater notification sent.")
|
||||||
|
return True
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warn(u"PlexPy Notifiers :: Plex Home Theater notification filed.")
|
logger.warn(u"PlexPy Notifiers :: Plex Home Theater notification filed.")
|
||||||
|
return False
|
||||||
|
|
||||||
def return_config_options(self):
|
def return_config_options(self):
|
||||||
config_option = [{'label': 'Plex Home Theater Host:Port',
|
config_option = [{'label': 'Plex Home Theater Host:Port',
|
||||||
|
@ -1278,12 +1283,11 @@ class TwitterNotifier(object):
|
||||||
try:
|
try:
|
||||||
api.PostUpdate(message)
|
api.PostUpdate(message)
|
||||||
logger.info(u"PlexPy Notifiers :: Twitter notification sent.")
|
logger.info(u"PlexPy Notifiers :: Twitter notification sent.")
|
||||||
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"PlexPy Notifiers :: Twitter notification failed: %s" % e)
|
logger.warn(u"PlexPy Notifiers :: Twitter notification failed: %s" % e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def return_config_options(self):
|
def return_config_options(self):
|
||||||
config_option = [{'label': 'Instructions',
|
config_option = [{'label': 'Instructions',
|
||||||
'description': 'Step 1: Visit <a href="' + helpers.anon_url('https://apps.twitter.com') + '" target="_blank"> \
|
'description': 'Step 1: Visit <a href="' + helpers.anon_url('https://apps.twitter.com') + '" target="_blank"> \
|
||||||
|
@ -2062,11 +2066,14 @@ class Scripts(object):
|
||||||
if error:
|
if error:
|
||||||
error = error.strip()
|
error = error.strip()
|
||||||
logger.error(u"PlexPy Notifiers :: Script error: %s" % error)
|
logger.error(u"PlexPy Notifiers :: Script error: %s" % error)
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
logger.info(u"PlexPy Notifiers :: Script notification sent.")
|
logger.info(u"PlexPy Notifiers :: Script notification sent.")
|
||||||
|
return True
|
||||||
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logger.error(u"PlexPy Notifiers :: Failed to run script: %s" % e)
|
logger.error(u"PlexPy Notifiers :: Failed to run script: %s" % e)
|
||||||
|
return False
|
||||||
|
|
||||||
def return_config_options(self):
|
def return_config_options(self):
|
||||||
config_option = [{'label': 'Supported File Types',
|
config_option = [{'label': 'Supported File Types',
|
||||||
|
@ -2313,11 +2320,11 @@ class FacebookNotifier(object):
|
||||||
try:
|
try:
|
||||||
api.put_wall_post(profile_id=self.group_id, message=message, attachment=attachment)
|
api.put_wall_post(profile_id=self.group_id, message=message, attachment=attachment)
|
||||||
logger.info(u"PlexPy Notifiers :: Facebook notification sent.")
|
logger.info(u"PlexPy Notifiers :: Facebook notification sent.")
|
||||||
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"PlexPy Notifiers :: Error sending Facebook post: %s" % e)
|
logger.warn(u"PlexPy Notifiers :: Error sending Facebook post: %s" % e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
logger.warn(u"PlexPy Notifiers :: Error sending Facebook post: No Facebook Group ID provided.")
|
logger.warn(u"PlexPy Notifiers :: Error sending Facebook post: No Facebook Group ID provided.")
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -1625,8 +1625,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
if this_agent:
|
if this_agent:
|
||||||
logger.debug(u"Sending test %s notification." % this_agent['name'])
|
logger.debug(u"Sending test %s notification." % this_agent['name'])
|
||||||
notifiers.send_notification(this_agent['id'], subject, body, 'test', **kwargs)
|
if notifiers.send_notification(this_agent['id'], subject, body, 'test', **kwargs):
|
||||||
return "Notification sent."
|
return "Notification sent."
|
||||||
|
else:
|
||||||
|
return "Notification failed."
|
||||||
else:
|
else:
|
||||||
logger.debug(u"Unable to send test notification, invalid notification agent ID %s." % agent_id)
|
logger.debug(u"Unable to send test notification, invalid notification agent ID %s." % agent_id)
|
||||||
return "Invalid notification agent ID %s." % agent_id
|
return "Invalid notification agent ID %s." % agent_id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue