diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 7e31c09..2b5feda 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -16,6 +16,7 @@ parameters: point_api_base_url: https://point.im/api/ point_use_https: true point_login: point-tools + point_id: 435 locale: en diff --git a/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php b/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php index 5371711..9986a4a 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php @@ -44,8 +44,14 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand /** @var SubscriptionsManager $subscriptionsManager */ $subscriptionsManager = $this->getContainer()->get('skobkin_point_tools.subscriptions_manager'); - $serviceUserName = $this->getContainer()->getParameter('point_login'); - $serviceUser = $this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('SkobkinPointToolsBundle:User')->findOneBy(['login' => $serviceUserName]); + try { + $serviceUserId = $this->getContainer()->getParameter('point_id'); + } catch (\InvalidArgumentException $e) { + $log->alert('Could not get point_id parameter from config file', ['exception_message' => $e->getMessage()]); + return false; + } + + $serviceUser = $this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('SkobkinPointToolsBundle:User')->find($serviceUserId); if (!$serviceUser) { $log->info('Service user not found'); @@ -59,7 +65,7 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand } try { - $serviceSubscribers = $api->getUserSubscribersByLogin($serviceUserName); + $serviceSubscribers = $api->getUserSubscribersById($serviceUserId); } catch (\Exception $e) { // @todo fallback to the local subscribers list $output->writeln('Error while getting service subscribers'); @@ -97,7 +103,7 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand $log->info('Processing @' . $user->getLogin()); try { - $userCurrentSubscribers = $api->getUserSubscribersByLogin($user->getLogin()); + $userCurrentSubscribers = $api->getUserSubscribersById($user->getId()); } catch (\Exception $e) { $output->writeln(' Error while getting subscribers. Skipping.'); $log->error('Error while getting subscribers.' . PHP_EOL .