Merge pull request #2323 from kijin/fcm-http-v1

Firebase (FCM) HTTP v1 API 지원
This commit is contained in:
Kijin Sung 2024-04-28 22:13:34 +09:00 committed by GitHub
commit 77b57627f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
227 changed files with 14001 additions and 2206 deletions

View file

@ -67,6 +67,12 @@ class Notification extends Base
$apns_certificate = Storage::read($apns_certificate_filename);
}
Context::set('apns_certificate', $apns_certificate);
$fcmv1_service_account = false;
if ($fcmv1_service_account_filename = config('push.fcmv1.service_account'))
{
$fcmv1_service_account = Storage::read($fcmv1_service_account_filename);
}
Context::set('fcmv1_service_account', $fcmv1_service_account);
// Workaround for compatibility with older version of Amazon SES driver.
config('mail.ses.api_key', config('mail.ses.api_user'));
@ -177,18 +183,36 @@ class Notification extends Base
}
$push_config[$driver_name][$conf_name] = $conf_value;
// Save certificates in a separate file and only store the filename in config.php.
if ($conf_name === 'certificate')
// Validate the FCM service account.
if ($conf_name === 'service_account' && $conf_value !== null)
{
$filename = Config::get('push.' . $driver_name . '.certificate');
$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')
{
$filename = Config::get('push.' . $driver_name . '.' . $conf_name);
if (!$filename)
{
$filename = './files/config/' . $driver_name . '/cert-' . \Rhymix\Framework\Security::getRandom(32) . '.pem';
if ($conf_name === 'certificate')
{
$filename = './files/config/' . $driver_name . '/cert-' . \Rhymix\Framework\Security::getRandom(32) . '.pem';
}
else
{
$filename = './files/config/' . $driver_name . '/pkey-' . \Rhymix\Framework\Security::getRandom(32) . '.json';
}
}
if ($conf_value !== null)
{
Storage::write($filename, $conf_value);
Storage::write('./files/config/' . $driver_name . '/index.html', '<!-- Direct Access Not Allowed -->');
$push_config[$driver_name][$conf_name] = $filename;
}
elseif (Storage::exists($filename))