Allow deleting mobile device using the registered device_id

This commit is contained in:
JonnyWong16 2020-10-11 13:55:50 -07:00
parent bee3361ace
commit d97b87d9cc
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 13 additions and 6 deletions

3
API.md
View file

@ -240,7 +240,8 @@ Remove a mobile device from the database.
```
Required parameters:
mobile_device_id (int): The device id to delete
mobile_device_id (int): The mobile device database id to delete, OR
device_id (str): The unique device identifier for the mobile device
Optional parameters:
None

View file

@ -149,13 +149,17 @@ def set_mobile_device_config(mobile_device_id=None, **kwargs):
return False
def delete_mobile_device(mobile_device_id=None):
def delete_mobile_device(mobile_device_id=None, device_id=None):
db = database.MonitorDatabase()
if mobile_device_id:
logger.debug("Tautulli MobileApp :: Deleting device_id %s from the database." % mobile_device_id)
logger.debug("Tautulli MobileApp :: Deleting mobile_device_id %s from the database." % mobile_device_id)
result = db.action('DELETE FROM mobile_devices WHERE id = ?', args=[mobile_device_id])
return True
elif device_id:
logger.debug("Tautulli MobileApp :: Deleting device_id %s from the database." % device_id)
result = db.action('DELETE FROM mobile_devices WHERE device_id = ?', args=[device_id])
return True
else:
return False

View file

@ -3823,12 +3823,13 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
@addtoapi()
def delete_mobile_device(self, mobile_device_id=None, **kwargs):
def delete_mobile_device(self, mobile_device_id=None, device_id=None, **kwargs):
""" Remove a mobile device from the database.
```
Required parameters:
mobile_device_id (int): The device id to delete
mobile_device_id (int): The mobile device database id to delete, OR
device_id (str): The unique device identifier for the mobile device
Optional parameters:
None
@ -3837,7 +3838,8 @@ class WebInterface(object):
None
```
"""
result = mobile_app.delete_mobile_device(mobile_device_id=mobile_device_id)
result = mobile_app.delete_mobile_device(mobile_device_id=mobile_device_id,
device_id=device_id)
if result:
return {'result': 'success', 'message': 'Deleted mobile device.'}
else: