Skip to content

Commit

Permalink
[Bot] add committees count into primo notification (#11278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano authored Jan 8, 2025
1 parent 2275e4c commit f36c9c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion features/api/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Feature:
"committee": {
"type": "committee",
"name": "En Marche Paris 8",
"assembly_committees_count": 0,
"assembly_committees_count": 2,
"can_change_committee": true,
"members_count": 0,
"message": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Entity\Adherent;
use App\Entity\Geo\Zone;
use App\Repository\AdherentRepository;
use App\Repository\CommitteeRepository;
use App\Utils\StringCleaner;
use App\ValueObject\Genders;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
Expand All @@ -21,6 +22,7 @@ class SendNewPrimoCotisationNotificationCommandHandler
{
public function __construct(
private readonly AdherentRepository $adherentRepository,
private readonly CommitteeRepository $committeeRepository,
private readonly ChatterInterface $chatter,
private readonly UrlGeneratorInterface $urlGenerator,
private readonly string $telegramChatIdPrimoAdhesion,
Expand Down Expand Up @@ -75,6 +77,10 @@ public function __invoke(SendNewPrimoCotisationNotificationCommand $command): vo

$zoneLines = StringCleaner::escapeMarkdown(implode("\n", $zoneLines));

if (!$committeeMembership) {
$zoneLines = "\n_".(($committeesInAdherentZone = \count($this->committeeRepository->findInAdherentZone($adherent))) ? $committeesInAdherentZone.' comité(s) dans l\'Assemblée' : 'Aucun comité dans l\'Assemblée').'_';
}

$smsSubscriber = $adherent->hasSmsSubscriptionType() ? '' : '';
$emailSubscriber = $adherent->isEmailSubscribed() ? '' : '';

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/CommitteeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function findInZones(array $zones, bool $withZoneParents = true): array

public function findInAdherentZone(Adherent $adherent): array
{
return $this->findInZones($adherent->getParentZonesOfType($adherent->isForeignResident() ? Zone::CUSTOM : Zone::DEPARTMENT));
return $this->findInZones([$adherent->getAssemblyZone()]);
}

public function findCommitteesForHost(Adherent $adherent): array
Expand Down

0 comments on commit f36c9c1

Please sign in to comment.