Check if notification agents enabled before sending notifications

This commit is contained in:
JonnyWong16 2016-02-28 22:17:03 -08:00
parent d73e379dcf
commit cc1e888227
4 changed files with 117 additions and 64 deletions

View file

@ -78,9 +78,10 @@ class ActivityProcessor(object):
result = self.db.upsert('sessions', values, keys)
if result == 'insert':
# Push any notifications - Push it on it's own thread so we don't hold up our db actions
if notify:
# Check if any notification agents have notifications enabled
if notify and any(d['on_play'] for d in notifiers.available_notification_agents()):
values.update({'ip_address': session['ip_address']})
# Push any notifications - Push it on it's own thread so we don't hold up our db actions
threading.Thread(target=notification_handler.notify,
kwargs=dict(stream_data=values, notify_action='play')).start()