Add settings for notification conditions filterer

This commit is contained in:
JonnyWong16 2017-05-05 23:14:11 -07:00
parent 565dea5ecf
commit f3349c64a9
5 changed files with 90 additions and 9 deletions

View file

@ -517,7 +517,8 @@ def dbcheck():
'on_resume_body TEXT, on_buffer_body TEXT, on_watched_body TEXT, '
'on_created_body TEXT, on_extdown_body TEXT, on_intdown_body TEXT, '
'on_extup_body TEXT, on_intup_body TEXT, on_pmsupdate_body TEXT, '
'on_concurrent_body TEXT, on_newdevice_body TEXT, on_plexpyupdate_body TEXT)'
'on_concurrent_body TEXT, on_newdevice_body TEXT, on_plexpyupdate_body TEXT, '
'custom_conditions TEXT, custom_conditions_logic TEXT)'
)
# poster_urls table :: This table keeps record of the notification poster urls
@ -1067,6 +1068,18 @@ def dbcheck():
logger.warn(u"Failed to recreate mobile_devices table.")
pass
# Upgrade notifiers table from earlier versions
try:
c_db.execute('SELECT custom_condition FROM notifiers')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table custom_condition.")
c_db.execute(
'ALTER TABLE notifiers ADD COLUMN custom_conditions TEXT'
)
c_db.execute(
'ALTER TABLE notifiers ADD COLUMN custom_conditions_logic TEXT'
)
# Add "Local" user to database as default unauthenticated user.
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
if not result.fetchone():

View file

@ -526,6 +526,8 @@ def set_notifier_config(notifier_id=None, agent_id=None, **kwargs):
'agent_label': agent['label'],
'friendly_name': kwargs.get('friendly_name', ''),
'notifier_config': json.dumps(notifier_config),
'custom_conditions': kwargs.get('custom_conditions', ''),
'custom_conditions_logic': kwargs.get('custom_conditions_logic', ''),
}
values.update(actions)
values.update(subject_text)

View file

@ -3032,6 +3032,35 @@ class WebInterface(object):
return serve_template(templatename="notifier_text_preview.html", text=text, agent=agent_name)
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
@addtoapi()
def get_notifier_parameters(self, **kwargs):
""" Get the list of available notification parameters.
```
Required parameters:
None
Optional parameters:
None
Returns:
json:
{
}
```
"""
parameters = [{'name': param['name'],
'type': param['type'],
'value': param['value']
}
for category in common.NOTIFICATION_PARAMETERS
for param in category['parameters']]
return parameters
@cherrypy.expose
@requireAuth(member_of("admin"))
@addtoapi("notify")