mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 22:23:36 -07:00
Fix issue where we may receive duplicate watched notifications when using websockets.
This commit is contained in:
parent
db543b8912
commit
447caa9e9e
2 changed files with 15 additions and 8 deletions
|
@ -378,8 +378,8 @@ from plexpy import common
|
|||
var pms_ip = $("#pms_ip").val().trim();
|
||||
var pms_port = $("#pms_port").val().trim();
|
||||
var pms_identifier = $("#pms_identifier").val();
|
||||
var pms_ssl = $("#pms_ssl").val();
|
||||
var pms_is_remote = $("#pms_is_remote").val();
|
||||
var pms_ssl = $("#pms_ssl").is(':checked') ? 1 : 0;
|
||||
var pms_is_remote = $("#pms_is_remote").is(':checked') ? 1 : 0;
|
||||
if ((pms_ip !== '') || (pms_port !== '')) {
|
||||
$("#pms-verify-status").html('<i class="fa fa-refresh fa-spin"></i> Validating server...');
|
||||
$('#pms-verify-status').fadeIn('fast');
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
import time
|
||||
import plexpy
|
||||
|
||||
from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler, helpers
|
||||
from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler, helpers, notifiers
|
||||
|
||||
|
||||
class ActivityHandler(object):
|
||||
|
@ -201,11 +201,18 @@ class ActivityHandler(object):
|
|||
self.on_start()
|
||||
|
||||
# Monitor if the stream has reached the watch percentage for notifications
|
||||
# The only purpose of this is for notifications
|
||||
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
||||
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT and this_state != 'buffering':
|
||||
threading.Thread(target=notification_handler.notify,
|
||||
kwargs=dict(stream_data=db_session, notify_action='watched')).start()
|
||||
# The only purpose of this is for notifications. Only process if any agents have on_watched toggled.
|
||||
if any(d['on_watched'] == 1 for d in notifiers.available_notification_agents()):
|
||||
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
||||
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT and this_state != 'buffering':
|
||||
# This is cheaper than having to send the request to notify each time.
|
||||
notify_states = notification_handler.get_notify_state(db_session)
|
||||
|
||||
# This is a bit hacky but we're unaware of agents here so just check if any watched
|
||||
# notifications are pending and allow it.
|
||||
if any(d['on_watched'] is None for d in notify_states):
|
||||
# Rather not put this on it's own thread so we know it completes before our next event.
|
||||
notification_handler.notify(stream_data=db_session, notify_action='watched')
|
||||
|
||||
else:
|
||||
# We don't have this session in our table yet, start a new one.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue