Edit warnings and respawn

This commit is contained in:
SimplifiedPrivacy 2026-11-08 18:40:33 -05:00
parent 37fae8a116
commit b396695721
4 changed files with 43 additions and 3 deletions

View file

@ -1,3 +1,4 @@
from core.services.config_tools.manage_sudo_configs import remove_sudo_config
from core.services.WebServiceApiService import WebServiceApiService
from core.observers.ConnectionObserver import ConnectionObserver
from core.controllers.ConnectionController import ConnectionController

View file

@ -1,3 +1,4 @@
from core.controllers.ProfileController import ProfileController
from core.services.subscriptions.subscriptions_by_protocol import wipe_billing_cycle
from core.services.payment_phase.payment_state import OverallPaymentCycle, TicketPaymentData
from core.controllers.ConfigurationController import ConfigurationController
@ -41,3 +42,34 @@ def wipe_ticket_cycle() -> Result:
return Result(valid=True)
else:
return Result(valid=False, error_type=ResultError.FILE_SYSTEM, message="Unable to wipe ticket billing cycle.")
def profile_can_respawn(profile_id: int) -> Result:
"""Check if a given profile can respawn"""
# Get profile object:
profile = ProfileController.get(profile_id)
logger.info(f"profile is {profile}")
if not profile:
error_msg = f"Invalid profile id of {profile_id}"
logger.error(error_msg)
return Result(valid=False, message=error_msg, error_type=ResultError.INVALID_INPUT)
if not profile.subscription:
error_msg = "This profile can not respawn, it lacks a subscription"
logger.info(error_msg)
return Result(valid=False, message=error_msg, error_type=ResultError.SUBSCRIPTION)
if not ConfigurationController.are_tickets_setup():
error_msg = "Tickets are not setup yet."
logger.info(error_msg)
return Result(valid=False, message=error_msg, error_type=ResultError.TICKET_SETUP)
if not profile.ticket:
error_msg = f"This profile can not respawn, it lacks a ticket. ticket is {profile.ticket}"
logger.info(error_msg)
return Result(valid=False, message=error_msg, error_type=ResultError.NO_TICKET)
return Result(valid=True)

View file

@ -41,6 +41,7 @@ def create_session_object(
protocol: ProtocolChoice,
location: Location,
name: str,
ticket: int|None,
application: Optional[ApplicationVersion] = None,
subscription: Optional[Subscription] = None
) -> Result:
@ -63,6 +64,7 @@ def create_session_object(
id=profile_id,
name=name,
subscription=subscription,
ticket=ticket,
type=ProfileType.SESSION,
location=location,
protocol=protocol,
@ -80,6 +82,7 @@ def create_system_object(
protocol: ProtocolChoice,
location: Location,
name: str,
ticket: int|None,
subscription: Optional[Subscription] = None
) -> Result:
"""Return a SessionProfile object"""
@ -90,6 +93,7 @@ def create_system_object(
type=ProfileType.SYSTEM,
protocol=protocol,
subscription=subscription,
ticket=ticket,
location=location,
connection=connection
)
@ -105,7 +109,7 @@ def create_new_profile_object(profile_id: int, potential_data: dict) -> Result:
#---------------------------
profile_type = potential_data.get('type', None)
protocol = potential_data.get('protocol', None)
ticket = potential_data.get('ticket', None)
raw_location = potential_data.get('location', None)
# already a location id:
@ -137,13 +141,13 @@ def create_new_profile_object(profile_id: int, potential_data: dict) -> Result:
# SESSION
#---------------------------
if profile_type == ProfileType.SESSION:
return create_session_object(profile_id=profile_id, potential_data=potential_data, protocol=protocol, location=location, name=name)
return create_session_object(profile_id=profile_id, potential_data=potential_data, protocol=protocol, location=location, name=name, ticket=ticket)
#---------------------------
# SYSTEM
#---------------------------
elif profile_type == ProfileType.SYSTEM:
return create_system_object(profile_id=profile_id, potential_data=potential_data, protocol=protocol, location=location, name=name)
return create_system_object(profile_id=profile_id, potential_data=potential_data, protocol=protocol, location=location, name=name, ticket=ticket)
#---------------------------
# OTHER

View file

@ -159,6 +159,7 @@ def create_profile_object_from_disk(profile_id: int) -> Result:
# SUBSCRIPTION
#========================================================
subscription = make_subscription_from_config(config_contents)
ticket = config_contents.get("ticket", None)
#========================================================
# PROFILE TYPE
@ -179,6 +180,7 @@ def create_profile_object_from_disk(profile_id: int) -> Result:
protocol=protocol,
location=location,
name=name,
ticket=ticket,
subscription=subscription
)
@ -196,6 +198,7 @@ def create_profile_object_from_disk(profile_id: int) -> Result:
protocol=protocol,
location=location,
name=name,
ticket=ticket,
application=application,
subscription=subscription
)