mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 07:46:07 -07:00
Allow formatting of ifttt event key with action name
This commit is contained in:
parent
2259a96058
commit
005829ab72
2 changed files with 9 additions and 6 deletions
|
@ -436,7 +436,7 @@ def get_notification_agent_config(agent_id):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def send_notification(agent_id, subject, body, **kwargs):
|
def send_notification(agent_id, subject, body, notify_action, **kwargs):
|
||||||
if str(agent_id).isdigit():
|
if str(agent_id).isdigit():
|
||||||
agent_id = int(agent_id)
|
agent_id = int(agent_id)
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ def send_notification(agent_id, subject, body, **kwargs):
|
||||||
tweet.notify(subject=subject, message=body)
|
tweet.notify(subject=subject, message=body)
|
||||||
elif agent_id == 12:
|
elif agent_id == 12:
|
||||||
iftttClient = IFTTT()
|
iftttClient = IFTTT()
|
||||||
iftttClient.notify(subject=subject, message=body)
|
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)
|
telegramClient.notify(message=body, event=subject)
|
||||||
|
@ -1604,10 +1604,11 @@ class IFTTT(object):
|
||||||
self.apikey = plexpy.CONFIG.IFTTT_KEY
|
self.apikey = plexpy.CONFIG.IFTTT_KEY
|
||||||
self.event = plexpy.CONFIG.IFTTT_EVENT
|
self.event = plexpy.CONFIG.IFTTT_EVENT
|
||||||
|
|
||||||
def notify(self, message, subject):
|
def notify(self, message, subject, action):
|
||||||
if not message or not subject:
|
if not message or not subject:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
event = unicode(self.event).format(action=action)
|
||||||
http_handler = HTTPSConnection("maker.ifttt.com")
|
http_handler = HTTPSConnection("maker.ifttt.com")
|
||||||
|
|
||||||
data = {'value1': subject.encode("utf-8"),
|
data = {'value1': subject.encode("utf-8"),
|
||||||
|
@ -1616,7 +1617,7 @@ class IFTTT(object):
|
||||||
# logger.debug(u"Ifttt SENDING: %s" % json.dumps(data))
|
# logger.debug(u"Ifttt SENDING: %s" % json.dumps(data))
|
||||||
|
|
||||||
http_handler.request("POST",
|
http_handler.request("POST",
|
||||||
"/trigger/%s/with/key/%s" % (self.event, self.apikey),
|
"/trigger/%s/with/key/%s" % (event, self.apikey),
|
||||||
headers={'Content-type': "application/json"},
|
headers={'Content-type': "application/json"},
|
||||||
body=json.dumps(data))
|
body=json.dumps(data))
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
|
@ -1649,7 +1650,9 @@ class IFTTT(object):
|
||||||
{'label': 'Ifttt Event',
|
{'label': 'Ifttt Event',
|
||||||
'value': self.event,
|
'value': self.event,
|
||||||
'name': 'ifttt_event',
|
'name': 'ifttt_event',
|
||||||
'description': 'The Ifttt maker event to fire. The notification subject and body will be sent'
|
'description': 'The Ifttt maker event to fire. You can include'
|
||||||
|
' the {action} to be substituted with the action name.'
|
||||||
|
' The notification subject and body will be sent'
|
||||||
' as value1 and value2 respectively.',
|
' as value1 and value2 respectively.',
|
||||||
'input_type': 'text'
|
'input_type': 'text'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1456,7 +1456,7 @@ 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, **kwargs)
|
notifiers.send_notification(this_agent['id'], subject, body, 'test', **kwargs)
|
||||||
return "Notification sent."
|
return "Notification sent."
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue