Skip to content

Commit

Permalink
[Community] add tradingview_email_confirmed accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Oct 7, 2024
1 parent 3004fdc commit a1b06d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions octobot/community/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ def _clear_bot_scoped_config(self):
self.save_tradingview_email("")
# also reset mqtt id to force a new mqtt id creation
self._save_mqtt_device_uuid("")
# will force reconfiguring the next email
self.save_tradingview_email_confirmed(False)

def clear_local_data_if_necessary(self):
if constants.IS_CLOUD_ENV:
Expand Down Expand Up @@ -744,6 +746,9 @@ def save_installed_package_urls(self, package_urls: list[str]):
def save_tradingview_email(self, tradingview_email: str):
self._save_value_in_config(constants.CONFIG_COMMUNITY_TRADINGVIEW_EMAIL, tradingview_email)

def save_tradingview_email_confirmed(self, confirmed: bool):
self._save_value_in_config(constants.CONFIG_COMMUNITY_TRADINGVIEW_EMAIL_CONFIRMED, confirmed)

def _save_mqtt_device_uuid(self, mqtt_uuid: str):
self._save_value_in_config(constants.CONFIG_COMMUNITY_MQTT_UUID, mqtt_uuid)

Expand All @@ -764,6 +769,9 @@ def _get_saved_bot_scoped_data_identifier(self) -> str:
def get_saved_tradingview_email(self) -> str:
return self._get_value_in_config(constants.CONFIG_COMMUNITY_TRADINGVIEW_EMAIL)

def is_tradingview_email_confirmed(self) -> bool:
return self._get_value_in_config(constants.CONFIG_COMMUNITY_TRADINGVIEW_EMAIL_CONFIRMED) is True

def _save_bot_id(self, bot_id):
self._save_value_in_config(constants.CONFIG_COMMUNITY_BOT_ID, bot_id)

Expand Down
1 change: 1 addition & 0 deletions octobot/community/feeds/community_mqtt_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ async def _config_feed_callback(self, data: dict):
email_body = parsed_message["code_email"]
self.logger.info(f"Received email address confirm code:\n{email_body}")
self.authenticator.user_account.last_email_address_confirm_code_email_content = email_body
self.authenticator.save_tradingview_email_confirmed(True)
else:
self.logger.error(f"Unknown cfg message action: {action=}")
if action and self._stop_on_cfg_action and self._stop_on_cfg_action.value == action:
Expand Down
1 change: 1 addition & 0 deletions octobot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
CONFIG_COMMUNITY_BOT_ID = "bot_id"
CONFIG_COMMUNITY_MQTT_UUID = "mqtt_uuid"
CONFIG_COMMUNITY_TRADINGVIEW_EMAIL = "tradingview_email"
CONFIG_COMMUNITY_TRADINGVIEW_EMAIL_CONFIRMED = "tradingview_email_confirmed"
CONFIG_COMMUNITY_PACKAGE_URLS = "package_urls"
CONFIG_COMMUNITY_ENVIRONMENT = "environment"
CONFIG_COMMUNITY_LOCAL_DATA_IDENTIFIER = "local_data_identifier"
Expand Down

0 comments on commit a1b06d3

Please sign in to comment.