diff --git a/modules/admin/controllers/systemconfig/Notification.php b/modules/admin/controllers/systemconfig/Notification.php
index 84d192a6d..0068d6a5a 100644
--- a/modules/admin/controllers/systemconfig/Notification.php
+++ b/modules/admin/controllers/systemconfig/Notification.php
@@ -183,6 +183,16 @@ class Notification extends Base
}
$push_config[$driver_name][$conf_name] = $conf_value;
+ // Validate the FCM service account.
+ if ($conf_name === 'service_account' && $conf_value !== null)
+ {
+ $decoded_value = @json_decode($conf_value, true);
+ if (!$decoded_value || !isset($decoded_value['project_id']) || !isset($decoded_value['private_key']))
+ {
+ throw new Exception('msg_advanced_mailer_invalid_fcm_json');
+ }
+ }
+
// Save certificates in a separate file and only store the filename in config.php.
if ($conf_name === 'certificate' || $conf_name === 'service_account')
{
diff --git a/modules/advanced_mailer/lang/en.php b/modules/advanced_mailer/lang/en.php
index 42d32d013..f4f4be412 100644
--- a/modules/advanced_mailer/lang/en.php
+++ b/modules/advanced_mailer/lang/en.php
@@ -153,3 +153,4 @@ $lang->cmd_advanced_mailer_updated_count = 'Updated';
$lang->cmd_advanced_mailer_not_rhymix = 'This module is for XE. It is incompatible with Rhymix. Please use the version included with Rhymix.';
$lang->msg_advanced_mailer_about_fcm_legacy = 'The FCM Legacy API will stop working after June 2024.
Please change to the HTTP v1 API and set up a service account private key.';
$lang->msg_advanced_mailer_about_fcm_service_account = 'Generate a new private key in the "Service accounts" menu of the Firebase console.
Then paste the contents of the downloaded JSON file above.';
+$lang->msg_advanced_mailer_invalid_fcm_json = 'The FCM service account you entered is not valid JSON.';
diff --git a/modules/advanced_mailer/lang/ko.php b/modules/advanced_mailer/lang/ko.php
index ffdba9ff1..3dd173fcd 100644
--- a/modules/advanced_mailer/lang/ko.php
+++ b/modules/advanced_mailer/lang/ko.php
@@ -153,3 +153,4 @@ $lang->cmd_advanced_mailer_updated_count = '변경';
$lang->cmd_advanced_mailer_not_rhymix = '이 모듈은 XE용으로, 라이믹스와는 호환되지 않습니다. 라이믹스에 기본 포함된 버전을 사용하시기 바랍니다.';
$lang->msg_advanced_mailer_about_fcm_legacy = 'FCM Legacy API는 2024년 6월 이후 사용할 수 없습니다.
HTTP v1 API로 변경하고 서비스 계정 비공개 키를 설정하십시오.';
$lang->msg_advanced_mailer_about_fcm_service_account = 'Firebase 콘솔의 "서비스 계정" 메뉴에서 비공개 키를 생성한 후,
다운로드한 JSON 파일의 내용을 빈 칸에 붙여넣으십시오.';
+$lang->msg_advanced_mailer_invalid_fcm_json = '입력하신 FCM 서비스 계정 파일 내용은 유효한 JSON이 아닙니다.';