Update commands now can fallback to API for point-tools user retrieval if it's not found in the database. Also small bug fixed.

This commit is contained in:
Alexey Skobkin 2019-01-19 02:07:00 +03:00
parent 2618398d06
commit 6c8c0829ca
2 changed files with 13 additions and 6 deletions

View file

@ -192,16 +192,19 @@ class UpdateSubscriptionsCommand extends Command
try {
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
} catch (\Exception $e) {
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $appUserId]);
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $this->appUserId]);
throw $e;
}
if (!$serviceUser) {
$this->logger->critical('Service user not found or marked as removed');
// @todo Retrieving user
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
throw new \RuntimeException('Service user not found in the database');
try {
$serviceUser = $this->api->getUserById($this->appUserId);
} catch (UserNotFoundException $e) {
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
}
}
$this->logger->info('Getting service subscribers');

View file

@ -164,9 +164,13 @@ class UpdateUsersPrivacyCommand extends Command
}
if (!$serviceUser) {
$this->logger->critical('Service user not found or marked as removed');
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
throw new \RuntimeException('Service user not found in the database');
try {
$serviceUser = $this->api->getUserById($this->appUserId);
} catch (UserNotFoundException $e) {
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
}
}
$this->logger->info('Getting service subscribers');