Use Ticket Controller returns Return objects
This commit is contained in:
parent
f038f7a8da
commit
ced69bfa4f
4 changed files with 26 additions and 8 deletions
|
|
@ -57,6 +57,12 @@ class ConfigurationController:
|
||||||
configuration.connection = connection
|
configuration.connection = connection
|
||||||
configuration.save()
|
configuration.save()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_connection_enum(connection_enum: ConnectionChoice) -> bool:
|
||||||
|
configuration = ConfigurationController.get_or_new()
|
||||||
|
configuration.connection = connection_enum
|
||||||
|
configuration.save()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_auto_sync_enabled():
|
def get_auto_sync_enabled():
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -344,3 +344,13 @@ class ProfileController:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def has_wireguard_configuration(profile: Union[SessionProfile, SystemProfile]):
|
def has_wireguard_configuration(profile: Union[SessionProfile, SystemProfile]):
|
||||||
return profile.has_wireguard_configuration()
|
return profile.has_wireguard_configuration()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def turn_on_assassin(profile: SessionProfile):
|
||||||
|
profile.assassin = True
|
||||||
|
profile.save()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def turn_off_assassin(profile: SessionProfile):
|
||||||
|
profile.assassin = False
|
||||||
|
profile.save()
|
||||||
|
|
|
||||||
|
|
@ -169,14 +169,16 @@ def use_ticket(
|
||||||
ticket_observer.notify("connecting", "Connecting..")
|
ticket_observer.notify("connecting", "Connecting..")
|
||||||
reply_object = use_ticket_orchestrator(which_ticket, which_location, connection_observer)
|
reply_object = use_ticket_orchestrator(which_ticket, which_location, connection_observer)
|
||||||
|
|
||||||
# TRANSLATE FOR UI
|
return reply_object
|
||||||
if reply_object.valid:
|
|
||||||
return {"valid": True, "billing_code": reply_object.data}
|
|
||||||
|
|
||||||
error_msg = reply_object.message
|
# TRANSLATE FOR UI
|
||||||
error_type = reply_object.error_type
|
# if reply_object.valid:
|
||||||
logger.error(f"Error Type: {error_type}")
|
# return {"valid": True, "billing_code": reply_object.data}
|
||||||
return {"valid": False, "message": error_msg, "error_type": error_type}
|
|
||||||
|
# error_msg = reply_object.message
|
||||||
|
# error_type = reply_object.error_type
|
||||||
|
# logger.error(f"Error Type: {error_type}")
|
||||||
|
# return {"valid": False, "message": error_msg, "error_type": error_type}
|
||||||
|
|
||||||
|
|
||||||
def pick_a_random_ticket(ticket_observer: TicketObserver) -> dict:
|
def pick_a_random_ticket(ticket_observer: TicketObserver) -> dict:
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ def use_ticket_orchestrator(
|
||||||
)
|
)
|
||||||
if not saved:
|
if not saved:
|
||||||
logger.error(f"Failed to save {which_ticket} is expired! That's okay the data is worthless to save.")
|
logger.error(f"Failed to save {which_ticket} is expired! That's okay the data is worthless to save.")
|
||||||
return Result(valid=False, error_type=ResultError.SUBSCRIPTION, message=f"This ticket {which_ticket}'s subscription is expired.")
|
return Result(valid=False, error_type=ResultError.SUBSCRIPTION, message=f"This ticket {which_ticket}'s subscription is expired. Do you want to wipe it?")
|
||||||
|
|
||||||
# UNKNOWN
|
# UNKNOWN
|
||||||
return Result(valid=False, error_type=ResultError.UNKNOWN, message=f"Unknown error with this data: {raw_data_dict}. {CUSTOMER_SERVICE_MSG}")
|
return Result(valid=False, error_type=ResultError.UNKNOWN, message=f"Unknown error with this data: {raw_data_dict}. {CUSTOMER_SERVICE_MSG}")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue