Use Ticket Controller returns Return objects

This commit is contained in:
SimplifiedPrivacy 2026-08-26 09:56:38 -04:00
parent f038f7a8da
commit ced69bfa4f
4 changed files with 26 additions and 8 deletions

View file

@ -57,6 +57,12 @@ class ConfigurationController:
configuration.connection = connection
configuration.save()
@staticmethod
def set_connection_enum(connection_enum: ConnectionChoice) -> bool:
configuration = ConfigurationController.get_or_new()
configuration.connection = connection_enum
configuration.save()
@staticmethod
def get_auto_sync_enabled():

View file

@ -344,3 +344,13 @@ class ProfileController:
@staticmethod
def has_wireguard_configuration(profile: Union[SessionProfile, SystemProfile]):
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()

View file

@ -169,14 +169,16 @@ def use_ticket(
ticket_observer.notify("connecting", "Connecting..")
reply_object = use_ticket_orchestrator(which_ticket, which_location, connection_observer)
# TRANSLATE FOR UI
if reply_object.valid:
return {"valid": True, "billing_code": reply_object.data}
return reply_object
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}
# TRANSLATE FOR UI
# if reply_object.valid:
# return {"valid": True, "billing_code": reply_object.data}
# 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:

View file

@ -106,7 +106,7 @@ def use_ticket_orchestrator(
)
if not saved:
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
return Result(valid=False, error_type=ResultError.UNKNOWN, message=f"Unknown error with this data: {raw_data_dict}. {CUSTOMER_SERVICE_MSG}")