Skip to content

Commit

Permalink
Merge pull request #987 from shankari/fix_push_again
Browse files Browse the repository at this point in the history
Fix silent push
  • Loading branch information
shankari authored Oct 6, 2024
2 parents 250c26e + acf6864 commit 593e61c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bin/push/push_remind.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import arrow
import json
import logging
logging.basicConfig(level=logging.INFO)
import os
import requests
import sys
Expand Down Expand Up @@ -55,7 +56,6 @@ def bin_users_by_lang(uuid_list, langs, lang_key='phone_lang'):


if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
logging.debug(f"STUDY_CONFIG is {STUDY_CONFIG}")

STUDY_CONFIG = os.getenv('STUDY_CONFIG', "stage-study")
Expand All @@ -68,12 +68,12 @@ def bin_users_by_lang(uuid_list, langs, lang_key='phone_lang'):
sys.exit(1)

dynamic_config = json.loads(r.text)
logging.debug(f"Successfully downloaded config with version {dynamic_config['version']} "\
logging.info(f"Successfully downloaded config with version {dynamic_config['version']} "\
f"for {dynamic_config['intro']['translated_text']['en']['deployment_name']} "\
f"and data collection URL {dynamic_config['server']['connectUrl']}")

if "reminderSchemes" in dynamic_config:
logging.debug("Found flexible notification configuration, skipping server-side push")
logging.info("Found flexible notification configuration, skipping server-side push")
sys.exit(0)

# get push notification config (if not present in dynamic_config, use default)
Expand All @@ -99,9 +99,9 @@ def bin_users_by_lang(uuid_list, langs, lang_key='phone_lang'):
# for each language, send a push notification to the selected users in that language
for lang, uuids_to_notify in filtered_uuids_by_lang.items():
if len(uuids_to_notify) == 0:
logging.debug(f"No users to notify in lang {lang}")
logging.info(f"No users to notify in lang {lang}")
continue
logging.debug(f"Sending push notifications to {len(uuids_to_notify)} users in lang {lang}")
logging.info(f"Sending push notifications to {len(uuids_to_notify)} users in lang {lang}")
json_data = {
"title": push_config["title"][lang],
"message": push_config["message"][lang],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_interface(push_config):
class FirebasePush(pni.NotifyInterface):
def __init__(self, push_config):
self.service_account_file = push_config.get("PUSH_SERVICE_ACCOUNT_FILE")
self.server_auth_token = push_config.get("PUSH_SERVER_AUTH_TOKEN")
self.project_id = push_config.get("PUSH_PROJECT_ID")
if "PUSH_APP_PACKAGE_NAME" in push_config:
self.app_package_name = push_config.get("PUSH_APP_PACKAGE_NAME")
Expand Down

0 comments on commit 593e61c

Please sign in to comment.