Adds ability to temporarily cache language selection upon account creation.

This commit is contained in:
philip 2021-12-29 17:15:28 +03:00
parent 54c9fe34ce
commit 9b639c4ea9
Signed by untrusted user: mango-habanero
GPG Key ID: B00CE9034DA19FB7
1 changed files with 12 additions and 3 deletions

View File

@ -32,14 +32,14 @@ celery_app = celery.current_app
@celery_app.task(bind=True, base=CriticalSQLAlchemyTask)
def account_creation_callback(self, result: str, url: str, status_code: int):
def account_creation_callback(self, result: str, param: str, status_code: int):
"""This function defines a task that creates a user and
:param self: Reference providing access to the callback task instance.
:type self: celery.Task
:param result: The blockchain address for the created account
:type result: str
:param url: URL provided to callback task in cic-eth should http be used for callback.
:type url: str
:param param: URL provided to callback task in cic-eth should http be used for callback.
:type param: str
:param status_code: The status of the task to create an account
:type status_code: int
"""
@ -69,6 +69,15 @@ def account_creation_callback(self, result: str, url: str, status_code: int):
set_active_token(blockchain_address=result, token_symbol=token_symbol)
queue = self.request.delivery_info.get('routing_key')
preferences_data = {"preferred_language": param}
# temporarily caching selected language
key = cache_data_key(bytes.fromhex(result), MetadataPointer.PREFERENCES)
cache_data(key, json.dumps(preferences_data))
s_preferences_metadata = celery.signature(
'cic_ussd.tasks.metadata.add_preferences_metadata', [result, preferences_data], queue=queue
)
s_preferences_metadata.apply_async()
s_phone_pointer = celery.signature(
'cic_ussd.tasks.metadata.add_phone_pointer', [result, phone_number], queue=queue
)