Getting use of tickets to flow into reconnects, using reconnect as an action to take

This commit is contained in:
SimplifiedPrivacy 2026-10-26 18:48:00 -04:00
parent 8721e078c4
commit 993c7f5ed9
2 changed files with 27 additions and 10 deletions

View file

@ -1,6 +1,9 @@
# core
# from core.services.networking.systemwide.systemwide_wireguard import change_port_then_reconnect
# from core.services.networking.ports.port_orchestrator import change_wg_port
from core.controllers.ConfigurationController import ConfigurationController
# from core.services.prepare_tickets.ticket_tracker import get_a_random_ticket
from core.models.BaseProfile import BaseProfile as Profile
from core.services.profiles.profile_connections import enable_profile, disable_profile
from core.controllers.ProfileController import ProfileController
from core.models.Configuration import Configuration, ConnectionChoice
@ -148,9 +151,10 @@ def NOT_need_tor_warnings(profile_id: int) -> Result:
@register_action(ResultError.ENDPOINT_VERIFICATION)
def literally_connect(
profile_id: int
) -> Result:
@register_action(ResultError.RECONNECT)
def literally_connect(profile_id: int) -> Result:
print(f"Literally Connecting...")
# Step 1: Get the Profile
profile_result = get_profile(profile_id)
@ -211,7 +215,7 @@ def _connect_profile(profile_id: int, passed_ui_caller: Callable) -> Result:
@type_checker
def connect_profile(profile_id: int, ui_caller: Callable) -> Result:
"""Type check before we thread"""
print("Threading to Connect..")
take_action(
action=_connect_profile,
ui_caller=ui_caller,
@ -221,7 +225,6 @@ def connect_profile(profile_id: int, ui_caller: Callable) -> Result:
return Result(valid=True)
def connect_with_billing_code(profile_id: int, billing_code: str) -> Result:
"""Apply a pre-existing billing code to a profile"""
@ -279,3 +282,12 @@ def disconnect_profile(profile_id: int, ui_caller: Callable) -> Result:
# ui_caller=ui_caller,
# profile_id=profile_id
# )
# @register_action(ResultError.PORT)
# def reconnect_with_port_change() -> Result:
# take_action(
# action=change_port_then_reconnect,
# ui_caller=ui_caller
# )

View file

@ -41,6 +41,9 @@ def wipe_ticket_billing() -> Result:
@register_action(ResultError.NO_TICKET)
def start_and_navigate_to_ticketing() -> Result:
"""Starts a new ticketing cycle. (assumes the user opted in)."""
logger.info("Doing start_and_navigate_to_ticketing")
start_result = start_new_payment_cycle(category=PaymentCategory.TICKET)
if start_result.valid:
logger.info("creating a new payment cycle was valid, it worked.")
@ -74,7 +77,8 @@ def random_ticket_dispatch(profile_id: int, passed_ui_caller: Callable) -> Resul
profile_id=profile_id,
which_ticket=which_ticket,
connection_observer=connection_observer,
ticket_observer=ticket_observer
ticket_observer=ticket_observer,
connect_after=True
)
return Result(valid=True)
@ -153,12 +157,12 @@ def get_ticket_data() -> Result:
message = ticket_results.get('message')
if not message:
message = "Error gathering ticket data"
Result(valid=False, error_type=ResultError.MISSING_FILE, message=message)
return Result(valid=False, error_type=ResultError.MISSING_FILE, message=message)
raw_tickets = ticket_results.get('data')
print(f"raw_tickets is {raw_tickets}")
if not raw_tickets:
Result(valid=False, error_type=ResultError.NO_TICKET, message="No tickets available. Would you like to get some?")
if not raw_tickets or raw_tickets is None:
return Result(valid=False, error_type=ResultError.NO_TICKET, message="No tickets available. Would you like to get some?")
formatted_data = [(f"Ticket #{t}", t) for t in raw_tickets]
print(f"formatted_data is {formatted_data}")
@ -174,5 +178,6 @@ def use_a_ticket(profile_id: int, which_ticket: int, ui_caller: Callable):
profile_id=profile_id,
which_ticket=which_ticket,
ticket_observer=ticket_observer,
connection_observer=connection_observer
connection_observer=connection_observer,
connect_after=True
)