Skip to content

Commit

Permalink
Merge branch 'develop' into release/2.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
pablothedude committed Aug 7, 2019
2 parents da74570 + 8ffda18 commit 1c7e4b1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Next release

## 2.1.14
* Use FCM always as fallback for GCM #80

## 2.1.13
* Update symfony/symfony and symfony/phpunit-bridge #79

Expand Down
4 changes: 0 additions & 4 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ parameters:
# PCRE as accepted by preg_match (http://php.net/preg_match).
mobile_app_user_agent_pattern: "/^.*$/"

# Flag to use Firebse as fallback when GCM fails with a MismatchSenderId.
# This is used to handle the push notification method rollover from GCM to Firebase.
use_firebase_fallback_for_gcm: true

# Options for the tiqr library
tiqr_library_options:
general:
Expand Down
30 changes: 7 additions & 23 deletions src/AppBundle/Controller/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,21 @@ class AuthenticationController extends Controller
private $authenticationRateLimitService;
private $userRepository;
private $stateHandler;
/**
* @var bool
*/
private $useFirebaseFallbackForGcm;

public function __construct(
AuthenticationService $authenticationService,
StateHandlerInterface $stateHandler,
TiqrServiceInterface $tiqrService,
TiqrUserRepositoryInterface $userRepository,
AuthenticationRateLimitServiceInterface $authenticationRateLimitService,
LoggerInterface $logger,
$useFirebaseFallbackForGcm
LoggerInterface $logger
) {
$this->authenticationService = $authenticationService;
$this->stateHandler = $stateHandler;
$this->tiqrService = $tiqrService;
$this->logger = $logger;
$this->authenticationRateLimitService = $authenticationRateLimitService;
$this->userRepository = $userRepository;
$this->useFirebaseFallbackForGcm = $useFirebaseFallbackForGcm;
}

/**
Expand Down Expand Up @@ -379,28 +373,18 @@ private function sendNotification($notificationType, $notificationAddress)
$notificationAddress
));

$result = $this->tiqrService->sendNotification($notificationType, $notificationAddress);
if (!$result
&& $notificationType == 'GCM'
&& $this->useFirebaseFallbackForGcm
&& $this->tiqrService->getNotificationError()['message'] == 'MismatchSenderId'
) {
// Retry with FCM if GCM
if ($notificationType == 'GCM') {
$notificationType = 'FCM';

$this->logger->notice(
sprintf(
'Failed to send push notification for type "%s" and address "%s" retrying with FCM',
$notificationType,
'GCM is not supported with address "%s" retrying with FCM',
$notificationAddress
),
[
'error_info' => $this->tiqrService->getNotificationError(),
]
)
);

$notificationType = 'FCM';
$result = $this->tiqrService->sendNotification($notificationType, $notificationAddress);
}

$result = $this->tiqrService->sendNotification($notificationType, $notificationAddress);
if (!$result) {
$this->logger->warning(
sprintf(
Expand Down
4 changes: 0 additions & 4 deletions src/AppBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,3 @@ services:
AppBundle\Service\UserAgentMatcher:
bind:
$pattern: '%mobile_app_user_agent_pattern%'

AppBundle\Controller\AuthenticationController:
bind:
$useFirebaseFallbackForGcm: '%use_firebase_fallback_for_gcm%'

0 comments on commit 1c7e4b1

Please sign in to comment.