diff --git a/server/src/uds/REST/methods/services.py b/server/src/uds/REST/methods/services.py index efe767ea..5f29a3ce 100644 --- a/server/src/uds/REST/methods/services.py +++ b/server/src/uds/REST/methods/services.py @@ -184,6 +184,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods raise self.invalidItemException() except IntegrityError: # Duplicate key probably if service and service.token: + service.delete() raise RequestError(_('Service token seems to be in use by other service. Please, select a new one.')) raise RequestError(_('Element already exists (duplicate key error)')) except services.Service.ValidationException as e: diff --git a/server/src/uds/core/managers/userservice/comms.py b/server/src/uds/core/managers/userservice/comms.py index e4d139ed..561946f1 100644 --- a/server/src/uds/core/managers/userservice/comms.py +++ b/server/src/uds/core/managers/userservice/comms.py @@ -126,16 +126,25 @@ def sendScript(userService: 'UserService', script: str, forUser: bool = False) - """ If allowed, send script to user service """ - _requestActor(userService, 'script', data={'script': script, 'user': forUser}, minVersion='3.0.0') + try: + _requestActor(userService, 'script', data={'script': script, 'user': forUser}, minVersion='3.0.0') + except NoActorComms: + pass def requestLogoff(userService: 'UserService') -> None: """ Ask client to logoff user """ - _requestActor(userService, 'logout', data={}) + try: + _requestActor(userService, 'logout', data={}) + except NoActorComms: + pass def sendMessage(userService: 'UserService', message: str) -> None: """ Sends an screen message to client """ - _requestActor(userService, 'message', data={'message':message}) + try: + _requestActor(userService, 'message', data={'message':message}) + except NoActorComms: + pass