mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 09:42:57 -07:00
Add device token to android app notifier config
This commit is contained in:
parent
d18c2ffddb
commit
8e13e2deb2
4 changed files with 27 additions and 29 deletions
|
@ -526,6 +526,12 @@ textarea.form-control:focus {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
.form-control[readonly] {
|
||||||
|
background-color: #555;
|
||||||
|
}
|
||||||
|
.form-control[readonly]:focus {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
.poster {
|
.poster {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 225px;
|
height: 225px;
|
||||||
|
@ -3037,12 +3043,6 @@ a:hover .overlay-refresh-image:hover {
|
||||||
#plex-log-levels label {
|
#plex-log-levels label {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
#api_key.form-control[readonly] {
|
|
||||||
background-color: #555;
|
|
||||||
}
|
|
||||||
#api_key.form-control[readonly]:focus {
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
#plexpy-notifiers-table .friendly_name,
|
#plexpy-notifiers-table .friendly_name,
|
||||||
#notifier-config-modal span.notifier_id {
|
#notifier-config-modal span.notifier_id {
|
||||||
color: #777;
|
color: #777;
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<label for="${item['name']}">${item['label']}</label>
|
<label for="${item['name']}">${item['label']}</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<input type="${item['input_type']}" class="form-control" id="${item['name']}" name="${item['name']}" value="${item['value']}" size="30">
|
<input type="${item['input_type']}" class="form-control" id="${item['name']}" name="${item['name']}" value="${item['value']}" size="30" ${'readonly' if item.get('readonly') else ''}>
|
||||||
% if item['name'] == 'osx_notify_app':
|
% if item['name'] == 'osx_notify_app':
|
||||||
<a href="javascript:void(0)" id="osxnotifyregister">Register</a>
|
<a href="javascript:void(0)" id="osxnotifyregister">Register</a>
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -341,13 +341,13 @@ class API2:
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def register_android_app(self, notifier_id=None, device_id='', **kwargs):
|
def register_android_app(self, notifier_id=None, device_token='', **kwargs):
|
||||||
""" Registers the PlexPy Android App for notifications.
|
""" Registers the PlexPy Android App for notifications.
|
||||||
|
|
||||||
```
|
```
|
||||||
Required parameters:
|
Required parameters:
|
||||||
notifier_id (int): The notifier id of the PlexPy Android App notifier
|
notifier_id (int): The notifier id of the PlexPy Android App notifier
|
||||||
device_id (str): The device id of the PlexPy Android App
|
device_token (str): The device token of the PlexPy Android App
|
||||||
|
|
||||||
Optional parameters:
|
Optional parameters:
|
||||||
None
|
None
|
||||||
|
@ -363,8 +363,8 @@ class API2:
|
||||||
self._api_result_type = 'error'
|
self._api_result_type = 'error'
|
||||||
return
|
return
|
||||||
|
|
||||||
elif not device_id:
|
elif not device_token:
|
||||||
self._api_msg = 'Device registartion failed: no device id provided.'
|
self._api_msg = 'Device registartion failed: no device token provided.'
|
||||||
self._api_result_type = 'error'
|
self._api_result_type = 'error'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -375,8 +375,8 @@ class API2:
|
||||||
self._api_result_type = 'error'
|
self._api_result_type = 'error'
|
||||||
return
|
return
|
||||||
|
|
||||||
config = {'androidapp_apikey': notifier['config']['apikey'],
|
config = {'androidapp_api_key': notifier['config']['api_key'],
|
||||||
'androidapp_deviceid': device_id}
|
'androidapp_device_token': device_token}
|
||||||
|
|
||||||
if notifiers.set_notifier_config(notifier_id=notifier_id, agent_id=notifier['agent_id'], **config):
|
if notifiers.set_notifier_config(notifier_id=notifier_id, agent_id=notifier['agent_id'], **config):
|
||||||
self._api_msg = 'Device registration successful.'
|
self._api_msg = 'Device registration successful.'
|
||||||
|
|
|
@ -665,32 +665,23 @@ class ANDROIDAPP(Notifier):
|
||||||
"""
|
"""
|
||||||
PlexPy Android App notifications
|
PlexPy Android App notifications
|
||||||
"""
|
"""
|
||||||
_DEFAULT_CONFIG = {'apikey': '',
|
_DEFAULT_CONFIG = {'api_key': '',
|
||||||
'deviceid': ''
|
'device_token': ''
|
||||||
}
|
}
|
||||||
|
|
||||||
def _register_device(self, apikey='', device_id=''):
|
|
||||||
config = {'apikey': apikey,
|
|
||||||
'deviceid': device_id}
|
|
||||||
|
|
||||||
if self.set_config(config):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def notify(self, subject='', body='', action='', **kwargs):
|
def notify(self, subject='', body='', action='', **kwargs):
|
||||||
if not subject or not body:
|
if not subject or not body:
|
||||||
return
|
return
|
||||||
|
|
||||||
data = {'to': self.config['deviceid'],
|
data = {'to': self.config['device_token'],
|
||||||
'data': {'subject': subject.encode("utf-8"),
|
'data': {'subject': subject.encode("utf-8"),
|
||||||
'body': body.encode("utf-8")}
|
'body': body.encode("utf-8")}
|
||||||
}
|
}
|
||||||
|
|
||||||
http_handler = HTTPSConnection("api.pushy.me")
|
http_handler = HTTPSConnection("api.pushy.me")
|
||||||
http_handler.request("POST",
|
http_handler.request("POST",
|
||||||
"/push",
|
"/push?%s" % urlencode({'api_key': self.config['api_key']}),
|
||||||
headers={
|
headers={'Content-type': "application/json"},
|
||||||
'Content-type': "application/json"
|
|
||||||
},
|
|
||||||
body=json.dumps(data))
|
body=json.dumps(data))
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
request_status = response.status
|
request_status = response.status
|
||||||
|
@ -707,10 +698,17 @@ class ANDROIDAPP(Notifier):
|
||||||
|
|
||||||
def return_config_options(self):
|
def return_config_options(self):
|
||||||
config_option = [{'label': 'Pushy API Key',
|
config_option = [{'label': 'Pushy API Key',
|
||||||
'value': self.config['apikey'],
|
'value': self.config['api_key'],
|
||||||
'name': 'androidapp_apikey',
|
'name': 'androidapp_api_key',
|
||||||
'description': 'Your Pushy API key.',
|
'description': 'Your Pushy API key.',
|
||||||
'input_type': 'text'
|
'input_type': 'text'
|
||||||
|
},
|
||||||
|
{'label': 'Device Token',
|
||||||
|
'value': self.config['device_token'],
|
||||||
|
'name': 'androidapp_device_token',
|
||||||
|
'description': 'Your Android App device token. Filled in automatically after registering the deivce in the app.',
|
||||||
|
'input_type': 'text',
|
||||||
|
'readonly': True
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue