mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +03:00
Updated actio to use match instead of ifs
This commit is contained in:
parent
e8db21b7ed
commit
5ac2e2a73d
@ -180,7 +180,9 @@ def action(request: 'ExtendedHttpRequestWithUser', service_id: str, action_strin
|
||||
response: typing.Any = None
|
||||
rebuild: bool = False
|
||||
if userservice:
|
||||
if action_string == 'release' and userservice.service_pool.allow_users_remove:
|
||||
match action_string:
|
||||
case 'release':
|
||||
if userservice.service_pool.allow_users_remove:
|
||||
rebuild = True
|
||||
log.log(
|
||||
userservice.service_pool,
|
||||
@ -192,11 +194,9 @@ def action(request: 'ExtendedHttpRequestWithUser', service_id: str, action_strin
|
||||
)
|
||||
UserServiceManager.manager().request_logoff(userservice)
|
||||
userservice.release()
|
||||
elif (
|
||||
action_string == 'reset'
|
||||
and userservice.service_pool.allow_users_reset
|
||||
and userservice.service_pool.service.get_type().can_reset
|
||||
):
|
||||
case 'reset':
|
||||
if userservice.service_pool.allow_users_reset and userservice.service_pool.service.get_type().can_reset:
|
||||
logger.info('Resetting service')
|
||||
rebuild = True
|
||||
log.log(
|
||||
userservice.service_pool,
|
||||
@ -208,6 +208,14 @@ def action(request: 'ExtendedHttpRequestWithUser', service_id: str, action_strin
|
||||
)
|
||||
# UserServiceManager.manager().requestLogoff(userService)
|
||||
UserServiceManager.manager().reset(userservice)
|
||||
# Rest, ignore
|
||||
case _:
|
||||
log.log(
|
||||
userservice.service_pool,
|
||||
types.log.LogLevel.ERROR,
|
||||
"Unknown action '{}' requested by {} from {}".format(action_string, request.user.pretty_name, request.ip),
|
||||
types.log.LogSource.WEB,
|
||||
)
|
||||
|
||||
if rebuild:
|
||||
# Rebuild services data, but return only "this" service
|
||||
|
Loading…
Reference in New Issue
Block a user