Skip to content

Commit

Permalink
Merge pull request #54 from humhub/fix/389-remove-legacy-driver
Browse files Browse the repository at this point in the history
Remove obsolete driver FcmLegacy
  • Loading branch information
luke- authored Oct 21, 2024
2 parents a7ff93e + dafcfc1 commit 048de8d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 85 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.1.0 (Unreleased)
-------------------------
- Fix #51: Firebase not working anymore for web push notifications
- Fix #54: Remove obsolete driver FcmLegacy

**This version requires extra settings in the module configuration.**

Expand Down
66 changes: 0 additions & 66 deletions driver/FcmLegacy.php

This file was deleted.

8 changes: 1 addition & 7 deletions models/ConfigureForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class ConfigureForm extends Model

public $json;

public $serverKey;

public $humhubApiKey;

public $disableAuthChoicesIos;
Expand Down Expand Up @@ -93,7 +91,7 @@ public function rules()
[['enableEmailGoService', 'disableAuthChoicesIos'], 'boolean'],
[['senderId'], 'number'],
[['firebaseApiKey', 'firebaseAppId', 'firebaseVapidKey'], 'string'],
[['serverKey', 'json', 'humhubApiKey'], 'safe'],
[['json', 'humhubApiKey'], 'safe'],
[['fileAssetLinks', 'fileAppleAssociation'], 'string'],
['json', function ($attribute, $params, $validator) {
if (empty($this->$attribute)) {
Expand Down Expand Up @@ -152,7 +150,6 @@ public function attributeLabels()
'firebaseAppId' => Yii::t('FcmPushModule.base', 'Web App ID'),
'firebaseVapidKey' => Yii::t('FcmPushModule.base', 'Key pair of the Web Push certificates'),
'json' => Yii::t('FcmPushModule.base', 'Service Account (JSON file)'),
'serverKey' => Yii::t('FcmPushModule.base', 'Cloud Messaging API (Legacy)'),
'disableAuthChoicesIos' => Yii::t('FcmPushModule.base', 'Disable AuthChoices on iOS App'),
'fileAssetLinks' => Yii::t('FcmPushModule.base', 'Well-known file {fileName}', [
'fileName' => '"' . WellKnownService::getFileName('fileAssetLinks') . '"',
Expand All @@ -168,7 +165,6 @@ public function attributeHints()
return [
'humhubInstallId' => Yii::t('FcmPushModule.base', 'Use this ID to register your API Key.'),
'firebaseVapidKey' => Yii::t('FcmPushModule.base', 'Firebase Cloud Messaging -> Web Push certificates -> Key pair'),
'serverKey' => Yii::t('FcmPushModule.base', 'Please switch to the new "Firebase Cloud Messaging API (V1)" and enter a JSON file in the field above. The old legacy API is only temporarily available for existing installations and is no longer supported or maintained.'),
'json' => Yii::t('FcmPushModule.base', 'Paste the content of the service account JSON files here. You can find more information in the module instructions.'),
'fileAssetLinks' => Yii::t('FcmPushModule.base', 'URL to the file {fileNameLink}', [
'fileNameLink' => Link::to(
Expand Down Expand Up @@ -202,7 +198,6 @@ public function loadSettings()
$this->firebaseAppId = $settings->get('firebaseAppId');
$this->firebaseVapidKey = $settings->get('firebaseVapidKey');
$this->json = $settings->get('json');
$this->serverKey = $settings->get('serverKey');
$this->humhubApiKey = $settings->get('humhubApiKey');
$this->disableAuthChoicesIos = $settings->get('disableAuthChoicesIos');
$this->fileAssetLinks = $settings->get('fileAssetLinks');
Expand All @@ -222,7 +217,6 @@ public function saveSettings()
$module->settings->set('firebaseAppId', $this->firebaseAppId);
$module->settings->set('firebaseVapidKey', $this->firebaseVapidKey);
$module->settings->set('json', $this->json);
$module->settings->set('serverKey', $this->serverKey);
$module->settings->set('humhubApiKey', $this->humhubApiKey);
$module->settings->set('disableAuthChoicesIos', $this->disableAuthChoicesIos);
$module->settings->set('fileAssetLinks', $this->fileAssetLinks);
Expand Down
11 changes: 2 additions & 9 deletions services/DriverService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use humhub\modules\fcmPush\driver\DriverInterface;
use humhub\modules\fcmPush\driver\Fcm;
use humhub\modules\fcmPush\driver\FcmLegacy;
use humhub\modules\fcmPush\driver\Proxy;
use humhub\modules\fcmPush\helpers\MobileAppHelper;
use humhub\modules\fcmPush\models\ConfigureForm;
Expand Down Expand Up @@ -33,19 +32,14 @@ private function initDrivers()
$fcm = new Fcm($this->config);
if ($fcm->isConfigured()) {
$this->configuredDrivers[] = $fcm;
} else {
$fcmLegacy = new FcmLegacy($this->config);
if ($fcmLegacy->isConfigured()) {
$this->configuredDrivers[] = $fcmLegacy;
}
}
}


/**
* There may be several Firebase drivers at the same time. e.g.
*
* - Fcm or FcmLegacy: For PWA/Web Notification
* - Fcm: For PWA/Web Notification
* - HumHubProxy: For the official Mobile Apps
*
* @return DriverInterface[]
Expand All @@ -55,12 +49,11 @@ public function getConfiguredDrivers(): array
return $this->configuredDrivers;
}


public function getWebDriver(): ?DriverInterface
{
// If Fcm driver is available use it
foreach ($this->configuredDrivers as $driver) {
if ($driver instanceof Fcm || $driver instanceof FcmLegacy) {
if ($driver instanceof Fcm) {
return $driver;
}
}
Expand Down
3 changes: 0 additions & 3 deletions views/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<?= $form->field($model, 'firebaseAppId') ?>
<?= $form->field($model, 'firebaseVapidKey') ?>
<?= $form->field($model, 'json')->textarea(['rows' => 10]); ?>
<?php if (!empty($model->serverKey)): ?>
<?= $form->field($model, 'serverKey')->textInput(); ?>
<?php endif; ?>
<br/>


Expand Down

0 comments on commit 048de8d

Please sign in to comment.