mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 21:51:14 -07:00
Update remote app notification agent platform specific settings
This commit is contained in:
parent
15c7212031
commit
b4598dca20
1 changed files with 53 additions and 40 deletions
|
@ -1,4 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# This file is part of Tautulli.
|
# This file is part of Tautulli.
|
||||||
#
|
#
|
||||||
|
@ -21,6 +21,7 @@ from future.builtins import object
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import bleach
|
import bleach
|
||||||
|
from collections import defaultdict
|
||||||
import json
|
import json
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
@ -3308,19 +3309,10 @@ class TAUTULLIREMOTEAPP(Notifier):
|
||||||
try:
|
try:
|
||||||
query = 'SELECT * FROM mobile_devices WHERE official = 1 ' \
|
query = 'SELECT * FROM mobile_devices WHERE official = 1 ' \
|
||||||
'AND onesignal_id IS NOT NULL AND onesignal_id != ""'
|
'AND onesignal_id IS NOT NULL AND onesignal_id != ""'
|
||||||
result = db.select(query=query)
|
return db.select(query=query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn("Tautulli Notifiers :: Unable to retrieve Tautulli Remote app devices list: %s." % e)
|
logger.warn("Tautulli Notifiers :: Unable to retrieve Tautulli Remote app devices list: %s." % e)
|
||||||
return {'': ''}
|
return []
|
||||||
|
|
||||||
devices = {}
|
|
||||||
for device in result:
|
|
||||||
if device['friendly_name']:
|
|
||||||
devices[device['device_id']] = device['friendly_name']
|
|
||||||
else:
|
|
||||||
devices[device['device_id']] = device['device_name']
|
|
||||||
|
|
||||||
return devices
|
|
||||||
|
|
||||||
def _return_config_options(self):
|
def _return_config_options(self):
|
||||||
config_option = []
|
config_option = []
|
||||||
|
@ -3345,12 +3337,12 @@ class TAUTULLIREMOTEAPP(Notifier):
|
||||||
'input_type': 'help'
|
'input_type': 'help'
|
||||||
})
|
})
|
||||||
|
|
||||||
config_option[-1]['description'] += '<br><br>Notifications are sent using the ' \
|
config_option[-1]['description'] += ('<br><br>Notifications are sent using '
|
||||||
'<a href="' + helpers.anon_url('https://onesignal.com') + '" target="_blank">' \
|
'<a href="' + helpers.anon_url('https://onesignal.com') + '" target="_blank">'
|
||||||
'OneSignal</a>. Some user data is collected and cannot be encrypted. ' \
|
'OneSignal</a>. Some user data is collected and cannot be encrypted.<br>'
|
||||||
'Please read the <a href="' + helpers.anon_url(
|
'Please read the <a href="' + helpers.anon_url(
|
||||||
'https://onesignal.com/privacy_policy') + '" target="_blank">' \
|
'https://onesignal.com/privacy_policy') + '" target="_blank">'
|
||||||
'OneSignal Privacy Policy</a> for more details.'
|
'OneSignal Privacy Policy</a> for more details.')
|
||||||
|
|
||||||
devices = self.get_devices()
|
devices = self.get_devices()
|
||||||
|
|
||||||
|
@ -3364,6 +3356,17 @@ class TAUTULLIREMOTEAPP(Notifier):
|
||||||
'input_type': 'help'
|
'input_type': 'help'
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
|
if len({d['platform'] for d in devices}) <= 1:
|
||||||
|
device_select = {d['device_id']: d['friendly_name'] or d['device_name'] for d in devices}
|
||||||
|
else:
|
||||||
|
device_select = defaultdict(list)
|
||||||
|
for d in devices:
|
||||||
|
platform = 'iOS' if d['platform'] == 'ios' else d['platform'].capitalize()
|
||||||
|
device_select[platform].append({
|
||||||
|
'value': d['device_id'],
|
||||||
|
'text': d['friendly_name'] or d['device_name']
|
||||||
|
})
|
||||||
|
|
||||||
config_option.append({
|
config_option.append({
|
||||||
'label': 'Device',
|
'label': 'Device',
|
||||||
'value': self.config['device_id'],
|
'value': self.config['device_id'],
|
||||||
|
@ -3373,16 +3376,25 @@ class TAUTULLIREMOTEAPP(Notifier):
|
||||||
'register a new device</a> with Tautulli.<br>'
|
'register a new device</a> with Tautulli.<br>'
|
||||||
'Note: Only devices registered with a valid OneSignal ID will appear in the list.',
|
'Note: Only devices registered with a valid OneSignal ID will appear in the list.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': devices
|
'select_options': device_select,
|
||||||
|
'refresh': True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
platform = next((d['platform'] for d in devices if d['device_id'] == self.config['device_id']), None)
|
||||||
|
|
||||||
|
if platform == 'android':
|
||||||
config_option.append({
|
config_option.append({
|
||||||
'label': 'Priority',
|
'label': 'Priority',
|
||||||
'value': self.config['priority'],
|
'value': self.config['priority'],
|
||||||
'name': 'remoteapp_priority',
|
'name': 'remoteapp_priority',
|
||||||
'description': 'Set the notification priority.',
|
'description': 'Set the notification priority.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': {1: 'Minimum', 2: 'Low', 3: 'Normal', 4: 'High'}
|
'select_options': {
|
||||||
|
1: 'Minimum',
|
||||||
|
2: 'Low',
|
||||||
|
3: 'Normal',
|
||||||
|
4: 'High'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
config_option.append({
|
config_option.append({
|
||||||
'label': 'Notification Image Type',
|
'label': 'Notification Image Type',
|
||||||
|
@ -3390,7 +3402,8 @@ class TAUTULLIREMOTEAPP(Notifier):
|
||||||
'name': 'remoteapp_notification_type',
|
'name': 'remoteapp_notification_type',
|
||||||
'description': 'Set the notification image type.',
|
'description': 'Set the notification image type.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': {0: 'No notification image',
|
'select_options': {
|
||||||
|
0: 'No notification image',
|
||||||
1: 'Small image (Expandable text)',
|
1: 'Small image (Expandable text)',
|
||||||
2: 'Large image (Non-expandable text)'
|
2: 'Large image (Non-expandable text)'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue