From 666a8f5649dcb08b8dfe5a1d4b9e1fda228967df Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Thu, 12 Sep 2024 08:51:15 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20add=20the=20configuration=20for?= =?UTF-8?q?=20HTTP=20v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The configuration that needs to be specified for v1 calls is different from the legacy FCM API https://github.com/olucurious/PyFCM?tab=readme-ov-file#updates-breaking-changes We now need to specify the path to the service account JSON file, and the project_id. Adding these to the config file temporarily so that we can test it on staging more easily. Once they are known to work, we can put them into the list of environment variables for the cloud services team to configure. --- conf/net/ext_service/push.json.sample | 4 +++- emission/net/ext_service/push/notify_interface.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/conf/net/ext_service/push.json.sample b/conf/net/ext_service/push.json.sample index af41a9582..b07208779 100644 --- a/conf/net/ext_service/push.json.sample +++ b/conf/net/ext_service/push.json.sample @@ -2,5 +2,7 @@ "provider": "firebase", "server_auth_token": "Get from firebase console", "app_package_name": "full package name from config.xml. e.g. edu.berkeley.eecs.emission or edu.berkeley.eecs.embase. Defaults to edu.berkeley.eecs.embase", - "ios_token_format": "fcm" + "ios_token_format": "fcm", + "project_id": "Get from the General project settings (https://console.cloud.google.com/project/_/settings/general/) tab of the Firebase console.", + "service_account_file": "Download according to the instructions at https://firebase.google.com/docs/cloud-messaging/migrate-v1#provide-credentials-manually and put the path to the file here" } diff --git a/emission/net/ext_service/push/notify_interface.py b/emission/net/ext_service/push/notify_interface.py index 04ed5d18d..77e47c89d 100644 --- a/emission/net/ext_service/push/notify_interface.py +++ b/emission/net/ext_service/push/notify_interface.py @@ -21,7 +21,8 @@ push_config = ecbc.get_config('conf/net/ext_service/push.json', {"PUSH_PROVIDER": "provider", "PUSH_SERVER_AUTH_TOKEN": "server_auth_token", - "PUSH_APP_PACKAGE_NAME": "app_package_name", "PUSH_IOS_TOKEN_FORMAT": "ios_token_format"}) + "PUSH_APP_PACKAGE_NAME": "app_package_name", "PUSH_IOS_TOKEN_FORMAT": "ios_token_format", + "PUSH_PROJECT_ID": "project_id", "PUSH_SERVICE_ACCOUNT_FILE": "service_account_file"}) try: logging.warning(f"Push configured for app {push_config.get('PUSH_APP_PACKAGE_NAME')} using platform {push_config.get('PUSH_PROVIDER')} with token {push_config.get('PUSH_SERVER_AUTH_TOKEN')[:10]}... of length {len(push_config.get('PUSH_SERVER_AUTH_TOKEN'))}")