mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Update notification handler for all notification triggers
This commit is contained in:
parent
1206d13978
commit
7b2a7aff9f
7 changed files with 245 additions and 1034 deletions
|
@ -97,11 +97,10 @@ class ActivityProcessor(object):
|
|||
|
||||
if result == 'insert':
|
||||
# Check if any notification agents have notifications enabled
|
||||
if notify and any(d['on_play'] for d in notifiers.available_notification_agents()):
|
||||
if notify:
|
||||
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()
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_notify_queue(
|
||||
stream_data=values, notify_action='on_play'))
|
||||
|
||||
# If it's our first write then time stamp it.
|
||||
started = int(time.time())
|
||||
|
@ -116,25 +115,11 @@ class ActivityProcessor(object):
|
|||
ip_address = {'ip_address': ip_address}
|
||||
self.db.upsert('sessions', ip_address, keys)
|
||||
|
||||
# Check if any notification agents have notifications enabled
|
||||
if notify and any(d['on_concurrent'] for d in notifiers.available_notification_agents()):
|
||||
# Check if any concurrent streams by the user
|
||||
user_sessions = self.get_session_by_user_id(user_id=session['user_id'],
|
||||
ip_address=plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP)
|
||||
if len(user_sessions) >= plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD:
|
||||
# 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='concurrent')).start()
|
||||
|
||||
# Check if any notification agents have notifications enabled
|
||||
if notify and any(d['on_newdevice'] for d in notifiers.available_notification_agents()):
|
||||
# Check if any concurrent streams by the user
|
||||
data_factory = datafactory.DataFactory()
|
||||
user_devices = data_factory.get_user_devices(user_id=session['user_id'])
|
||||
if session['machine_id'] not in user_devices:
|
||||
# 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='newdevice')).start()
|
||||
if notify:
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_notify_queue(
|
||||
stream_data=values, notify_action='on_concurrent'))
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_notify_queue(
|
||||
stream_data=values, notify_action='on_newdevice'))
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue