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.services.WebServiceApiService import WebServiceApiService
from core.observers.ConnectionObserver import ConnectionObserver from core.observers.ConnectionObserver import ConnectionObserver
from core.controllers.ConnectionController import ConnectionController 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.subscriptions.subscriptions_by_protocol import wipe_billing_cycle
from core.services.payment_phase.payment_state import OverallPaymentCycle, TicketPaymentData from core.services.payment_phase.payment_state import OverallPaymentCycle, TicketPaymentData
from core.controllers.ConfigurationController import ConfigurationController from core.controllers.ConfigurationController import ConfigurationController
@ -41,3 +42,34 @@ def wipe_ticket_cycle() -> Result:
return Result(valid=True) return Result(valid=True)
else: else:
return Result(valid=False, error_type=ResultError.FILE_SYSTEM, message="Unable to wipe ticket billing cycle.") 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, protocol: ProtocolChoice,
location: Location, location: Location,
name: str, name: str,
ticket: int|None,
application: Optional[ApplicationVersion] = None, application: Optional[ApplicationVersion] = None,
subscription: Optional[Subscription] = None subscription: Optional[Subscription] = None
) -> Result: ) -> Result:
@ -63,6 +64,7 @@ def create_session_object(
id=profile_id, id=profile_id,
name=name, name=name,
subscription=subscription, subscription=subscription,
ticket=ticket,
type=ProfileType.SESSION, type=ProfileType.SESSION,
location=location, location=location,
protocol=protocol, protocol=protocol,
@ -80,6 +82,7 @@ def create_system_object(
protocol: ProtocolChoice, protocol: ProtocolChoice,
location: Location, location: Location,
name: str, name: str,
ticket: int|None,
subscription: Optional[Subscription] = None subscription: Optional[Subscription] = None
) -> Result: ) -> Result:
"""Return a SessionProfile object""" """Return a SessionProfile object"""
@ -90,6 +93,7 @@ def create_system_object(
type=ProfileType.SYSTEM, type=ProfileType.SYSTEM,
protocol=protocol, protocol=protocol,
subscription=subscription, subscription=subscription,
ticket=ticket,
location=location, location=location,
connection=connection 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) profile_type = potential_data.get('type', None)
protocol = potential_data.get('protocol', None) protocol = potential_data.get('protocol', None)
ticket = potential_data.get('ticket', None)
raw_location = potential_data.get('location', None) raw_location = potential_data.get('location', None)
# already a location id: # already a location id:
@ -137,13 +141,13 @@ def create_new_profile_object(profile_id: int, potential_data: dict) -> Result:
# SESSION # SESSION
#--------------------------- #---------------------------
if profile_type == ProfileType.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 # SYSTEM
#--------------------------- #---------------------------
elif profile_type == ProfileType.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 # OTHER

View file

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