From 9b639c4ea95b7bb229021bfa965af7d0e386eae2 Mon Sep 17 00:00:00 2001 From: philip Date: Wed, 29 Dec 2021 17:15:28 +0300 Subject: [PATCH] Adds ability to temporarily cache language selection upon account creation. --- apps/cic-ussd/cic_ussd/tasks/callback_handler.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/cic-ussd/cic_ussd/tasks/callback_handler.py b/apps/cic-ussd/cic_ussd/tasks/callback_handler.py index 08bd56fa..827e1b46 100644 --- a/apps/cic-ussd/cic_ussd/tasks/callback_handler.py +++ b/apps/cic-ussd/cic_ussd/tasks/callback_handler.py @@ -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 )