<?php
namespace App\EventSubscriber\App;
use App\Entity\AutomatedEmailNotificationDefinition\AutomatedEmailNotificationDefinitionTextContent;
use App\Entity\ExternalPartner\IntegratedExternalPartnerCustomer;
use App\Entity\PlatformEvent;
use App\Entity\PlatformSite;
use App\Event\ExtendedApplicationCreatedEvent;
use App\Event\ExtendedApplicationReadByJoboffererEvent;
use App\Service\AutomatedEmailNotificationDefinitionService;
use App\Service\ConversationMessageService;
use App\Service\ConversionEventService;
use App\Service\ExternalFeedsService;
use App\Service\ExternalPartner\IntegratedExternalPartnerCustomerService;
use App\Service\MailService;
use App\Service\OnetimeLoginTokenService;
use App\Service\PlatformEventService;
use App\Service\ProfileService;
use App\Service\RouterHelperService;
use App\SymfonyMessage\AskNewUserForGoogleRatingSymfonyMessage;
use App\SymfonyMessage\UpdateCachedUnreadConversationMessagesCountSymfonyMessage;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use JanusHercules\DatawarehouseIntegration\Domain\Entity\BusinessEvent;
use JanusHercules\DatawarehouseIntegration\Domain\Entity\ExternalPartnerEvent;
use JanusHercules\DatawarehouseIntegration\Domain\Service\BusinessEventDomainService;
use JanusHercules\DatawarehouseIntegration\Domain\Service\ExternalPartnerEventDomainService;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Throwable;
use Twig\Environment;
readonly class ExtendedApplicationEventSubscriber implements EventSubscriberInterface
{
public function __construct(
private ConversionEventService $conversionEventService,
private ExternalPartnerEventDomainService $externalPartnerEventDomainService,
private BusinessEventDomainService $businessEventDomainService,
private MailService $mailService,
private Environment $twigEnvironment,
private OnetimeLoginTokenService $onetimeLoginTokenService,
private RouterHelperService $routerHelperService,
private IntegratedExternalPartnerCustomerService $integratedExternalPartnerCustomerService,
private EntityManagerInterface $entityManager,
private ProfileService $profileService,
private MessageBusInterface $messageBus,
private PlatformEventService $platformEventService,
private LoggerInterface $logger
) {
}
public static function getSubscribedEvents(): array
{
return [
ExtendedApplicationCreatedEvent::class => 'onExtendedApplicationCreated',
ExtendedApplicationReadByJoboffererEvent::class => 'onExtendedApplicationReadByJobofferer'
];
}
/** @throws Exception */
public function onExtendedApplicationCreated(ExtendedApplicationCreatedEvent $event): void
{
try {
/* @see ConversationMessageService::getUnreadMessagesCount — unread extended applications count as unread messages, too */
$joboffererUser = $event->getExtendedApplication()
->getRecurrentJob()
?->getJoboffererProfile()
->getUser();
if (!is_null($joboffererUser)) {
$this->messageBus->dispatch(
new UpdateCachedUnreadConversationMessagesCountSymfonyMessage(
$joboffererUser
)
);
}
$userHasBeenNewlyCreatedByThisExtendedApplication = $event->userHasBeenNewlyCreatedByThisExtendedApplication();
// If as user has been newly created by this extended application,
// we don't want to track the conversion goals here because they are
// already tracked in the UserEventSubscriber.
if (!$userHasBeenNewlyCreatedByThisExtendedApplication) {
foreach ([ConversionEventService::CAMPAIGN_ID_JOBLIFT,
ConversionEventService::CAMPAIGN_ID_TALENTCOM,
ConversionEventService::CAMPAIGN_ID_STELLENONLINE
] as $campaignId
) {
foreach ([0, 1, 2, 3, 4, 5, 6, 12] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
$campaignId,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
}
foreach ([0, 1, 2, 7, 8, 9, 10, 11, 12, 13] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_MEINESTADT,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1, 2, 3, 4, 5] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_JOBIJOBA,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1, 2, 3, 4, 5, 6] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_WHATJOBS,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1, 2, 3] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_JOOBLE,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_PERSOMATCH_FEED,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_LINKED_IN,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
// subcampaign id 3 currently doesn't get tracked on extended application creation for Stellenonline
if (!is_null($recurrentJob = $event->getExtendedApplication()->getRecurrentJob())
&& $recurrentJob->belongsToIntegratedExternalPartnerCustomer()
&& !is_null($customer = $recurrentJob->getIntegratedExternalPartnerCustomer())
&& $customer->getInternalId() === IntegratedExternalPartnerCustomer::INTERNAL_ID_DEUTSCHE_BAHN_AG
) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_TALENTCOM,
4,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_STELLENONLINE,
4,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_JOBLIFT,
4,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
} elseif (!is_null($recurrentJob = $event->getExtendedApplication()->getRecurrentJob())
&& $recurrentJob->belongsToIntegratedExternalPartnerCustomer()
&& !is_null($customer = $recurrentJob->getIntegratedExternalPartnerCustomer())
&& $customer->getInternalId() === IntegratedExternalPartnerCustomer::INTERNAL_ID_WISAG_CONCLUDIS_API
) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_STELLENONLINE,
5,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_JOBLIFT,
5,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
} elseif (!is_null($recurrentJob = $event->getExtendedApplication()->getRecurrentJob())
&& $recurrentJob->belongsToIntegratedExternalPartnerCustomer()
&& !is_null($customer = $recurrentJob->getIntegratedExternalPartnerCustomer())
&& $customer->getInternalId() === IntegratedExternalPartnerCustomer::INTERNAL_ID_MEINESTADT_DE
) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_TALENTCOM,
6,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_STELLENONLINE,
6,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1, 2] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_CRITEO,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach (ExternalFeedsService::EBAY_SUBCAMPAIGN_VARIANTS as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_EBAY,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach (range(0, 1000) as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_FACEBOOK,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_INSTAGRAM,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_EASY_LEBENSLAUF,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_EASY_LEBENSLAUF,
1,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
foreach (range(0, 31) as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_LANDINGPAGES,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1, 2, 3] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_BING_LANDINGPAGES,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_JOBWARE,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_AGENTUR_FUER_ARBEIT,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_SIMILAR_JOBS,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_GOOGLE_FOR_JOBS,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
foreach ([0, 1] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_GMX,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_WHATSAPP_MESSAGE_ABOUT_UNREAD_INTEGRATED_EXTERNAL_PARTNER_CUSTOMER_PREMIUM_RADAR_MESSAGE,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob(),
null,
json_encode(['goalReachedBy' => 'extendedApplication'])
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_WHATSAPP_MESSAGE_ABOUT_UNREAD_LEAD_CONVERSION_RADAR_MESSAGE,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob(),
null,
json_encode(['goalReachedBy' => 'extendedApplication'])
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_WHATSAPP_MESSAGE_ABOUT_UNREAD_LEAD_CONVERSION_RADAR_MESSAGE,
1,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob(),
null,
json_encode(['goalReachedBy' => 'extendedApplication'])
);
foreach ([0, 1, 2] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_INTERNAL_APPLICATION_TRACKING_RECURRENT_JOBS_SEARCH,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1, 2] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_INTERNAL_APPLICATION_TRACKING_RECURRENT_JOBS_SEARCH_ALL_JOBS,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_INTERNAL_APPLICATION_TRACKING_AUTOMATED_CONVERSATION_MESSAGES_MAILING,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
foreach ([0, 1] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_INTERNAL_APPLICATION_TRACKING_INTEGRATED_EXTERNAL_PARTNER_CUSTOMER_PREMIUM_RADAR,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_XING_FEED,
0,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
}
if (!is_null($event->getExtendedApplication()->getRecurrentJob())
&& !is_null($event->getExtendedApplication()->getRecurrentJob()->getExternalPartner())
) {
$this->externalPartnerEventDomainService->writeEvent(
ExternalPartnerEvent::EVENT_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED,
$event->getExtendedApplication()->getRecurrentJob()->getExternalPartner(),
$event->getExtendedApplication()->getRecurrentJob(),
$event->getExtendedApplication()->getRecurrentJob()->getQuota(),
null,
null,
null,
null,
$event->getUser(),
$event->getRequest(),
$event->getConversionCampaignId(),
$event->getPlatformSiteId(),
null,
null,
$event->getExtendedApplication()
);
}
$recurrentJob = $event->getExtendedApplication()->getRecurrentJob();
$joboffererProfile = null;
$withoutFiles = is_null($event->getExtendedApplication()->getPrimaryCvFile())
&& is_null($event->getExtendedApplication()->getSecondaryCvFile());
$additionalData = [
'withoutFiles' => $withoutFiles,
'source' => $event->getExtendedApplication()->getCreatedViaCampaignId(),
'extendedApplicationId' => $event->getExtendedApplication()->getId(),
'recurrentJobZipcode' => null
];
if (!is_null($recurrentJob)) {
$joboffererProfile = $recurrentJob->getJoboffererProfile();
$dataToAdd = [
'occupationalFieldSearchterm' => $event->getExtendedApplication()->getRecurrentJob()->getOccupationalFieldSearchterm(),
'recurrentJobId' => $event->getExtendedApplication()->getRecurrentJob()->getId(),
'internalId' => !is_null($event->getExtendedApplication()->getRecurrentJob()->getIntegratedExternalPartnerCustomer())
? $event->getExtendedApplication()->getRecurrentJob()->getIntegratedExternalPartnerCustomer()->getInternalId()
: null,
'recurrentJobZipcode' => $event->getExtendedApplication()->getRecurrentJob()->getZipcode(),
'recurrentJobBusinessName' => $event->getExtendedApplication()->getRecurrentJobBusinessName(),
'recurrentJobTitel' => $event->getExtendedApplication()->getRecurrentJob()->getTitle()
];
$additionalData = [...$additionalData, ...$dataToAdd];
}
if (!is_null($joboffererProfile)
&& !is_null($joboffererProfile->getEconomicSector())
&& !is_null($joboffererProfile->getEconomicSector()->getTitle())
) {
$additionalData = [
...$additionalData,
'economicSector' => $joboffererProfile->getEconomicSector()->getTitle(),
];
}
$additionalData = json_encode($additionalData);
$this->businessEventDomainService->writeNewEvent(
BusinessEvent::EVENT_TYPE_EXTENDED_APPLICATION_FORM_COMPLETED,
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob(),
null,
$additionalData
);
if ($event->getPlatformSiteId() === PlatformSite::PLATFORM_SITE_ID_RECRUIT_DL) {
$this->businessEventDomainService->writeNewEvent(
BusinessEvent::EVENT_TYPE_INDEED_RECRUIT_DL_FORM_COMPLETED,
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob(),
null,
$additionalData
);
}
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_EXTENDED_APPLICATION,
0,
$event->getRequest(),
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_EXTENDED_APPLICATION,
1,
$event->getRequest(),
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_INDEED_RECRUIT_DL_CONTENT_DISTRIBUTION_VIA_XML_FEED,
0,
$event->getRequest(),
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_RECRUIT_DL_LANDINGPAGE,
0,
$event->getRequest(),
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_SHARED_RECURRENT_JOBS,
0,
$event->getRequest(),
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_RECURRENT_JOBS_TO_PRINT_QR_CODE,
0,
$event->getRequest(),
$event->getExtendedApplication()->getJobseekerProfile()->getUser(),
$event->getExtendedApplication()->getRecurrentJob()
);
foreach ([0, 1, 2, 3, 4, 5, 6, 7] as $subcampaignId) {
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_RECURRENT_JOBS_SEARCH_FOR_ONE_SPECIFIC_CUSTOMER,
$subcampaignId,
$event->getRequest(),
$event->getUser(),
$event->getExtendedApplication()->getRecurrentJob(),
null,
null,
!is_null($event->getExtendedApplication()->getRecurrentJob())
? $event->getExtendedApplication()->getRecurrentJob()->getIntegratedExternalPartnerCustomer()
: null
);
}
if ($event->getPlatformSiteId() === PlatformSite::PLATFORM_SITE_ID_JOBOO && $event->getUser()->hasJobseekerProfile()) {
$this->profileService->activateHiddenWantedJobsForProfile(
$event->getUser()
->getDefaultJobseekerProfile()
);
}
if ($event->getUser()->isEnabled()
) {
if ($event->getPlatformSiteId() === PlatformSite::PLATFORM_SITE_ID_RECRUIT_DL) {
$message = $this->mailService->createMessage(
'Deine Bewerbung',
$this->twigEnvironment->render(
'/extended_application/info_about_new_application.html.twig',
[
'firstname' => $event->getExtendedApplication()->getFirstname(),
'zipcode' => $event->getExtendedApplication()->getRecurrentJob()->getZipcode(),
'searchterm' => $event->getExtendedApplication()->getRecurrentJob()->getOccupationalFieldSearchtermForDisplay(),
'businessName' => $event->getExtendedApplication()->getRecurrentJobBusinessName(),
'link' => $this->routerHelperService->replaceRecruitDlAndJobooOnlineInUri(
$this->onetimeLoginTokenService->generateOneTimeLoginUrl(
OnetimeLoginTokenService::REDIRECT_KEY_CONVERSATIONS_SHOW_EXTENDED_APPLICATIONS_JOBSEEKER,
$event->getUser(),
['id' => $event->getExtendedApplication()->getJobseekerProfile()->getId()],
ConversionEventService::CAMPAIGN_ID_EXTENDED_APPLICATION_EMAIL_LINK_TO_CONVERSATION_MESSAGE_EXTENDED_APPLICATION_OVERVIEW,
1,
$event->getExtendedApplication()->getRecurrentJob()
)
),
'platformSiteId' => $event->getPlatformSiteId(),
]
),
$event->getExtendedApplication()->getEmail(),
'info@recruit-dl.de',
'mailfromname.recruit-dl'
);
$message->setContentType('text/html');
} else {
/** @var AutomatedEmailNotificationDefinitionTextContent $textContent */
$textContent = $this
->entityManager
->getRepository(AutomatedEmailNotificationDefinitionTextContent::class)
->findOneBy(
[
'automatedEmailNotificationDefinition' => MailService::MAIL_ID_INFO_TO_ENABLED_JOBSEEKER_ABOUT_EXTENDED_APPLICATION,
'subjectId' => AutomatedEmailNotificationDefinitionService::SUBJECT_ID_INFO_TO_ENABLED_JOBSEEKER_ABOUT_EXTENDED_APPLICATION
]
);
$message = $this->mailService->createMessage(
$textContent->getSubject(),
$this->twigEnvironment->render(
$textContent->getTwigTemplateName(),
[
'firstname' => $event->getExtendedApplication()->getFirstname(),
'zipcode' => $event->getExtendedApplication()->getRecurrentJob()->getZipcode(),
'searchterm' => $event->getExtendedApplication()->getRecurrentJob()->getOccupationalFieldSearchtermForDisplay(),
'businessName' => $event->getExtendedApplication()->getRecurrentJobBusinessName(),
'link' => $this->routerHelperService->replaceRecruitDlAndJobooOnlineInUri(
$this->onetimeLoginTokenService->generateOneTimeLoginUrl(
OnetimeLoginTokenService::REDIRECT_KEY_CONVERSATIONS_SHOW_EXTENDED_APPLICATIONS_JOBSEEKER,
$event->getUser(),
['id' => $event->getExtendedApplication()->getJobseekerProfile()->getId()],
ConversionEventService::CAMPAIGN_ID_EXTENDED_APPLICATION_EMAIL_LINK_TO_CONVERSATION_MESSAGE_EXTENDED_APPLICATION_OVERVIEW,
1,
$event->getExtendedApplication()->getRecurrentJob(),
null,
null,
UrlGeneratorInterface::ABSOLUTE_URL,
false,
$textContent->getAutomatedEmailNotificationDefinition()->getId(),
$textContent->getBodyId()
)
),
'platformSiteId' => $event->getPlatformSiteId(),
]
),
$event->getExtendedApplication()->getEmail(),
MailService::DEFAULT_SENDER_NOREPLY_MAILADDRESS,
'direct_email_communication.outgoing_message.noreply_sender_name'
);
$message->setContentType('text/html');
}
$this->mailService->queueForSending(
MailService::MAIL_ID_INFO_TO_ENABLED_JOBSEEKER_ABOUT_EXTENDED_APPLICATION,
$message,
$event->getExtendedApplication()->getJobseekerProfile()->getUser()
);
}
if ($event->getPlatformSiteId() === PlatformSite::PLATFORM_SITE_ID_JOBOO
|| $event->getPlatformSiteId() === PlatformSite::PLATFORM_SITE_ID_JOBOO_ONLINE
) {
$jobseekerProfile = $event->getExtendedApplication()->getJobseekerProfile();
if (!is_null($jobseekerProfile)) {
if (!$this->platformEventService->hasEventOccuredInLastNDaysForAdditionalData(
PlatformEvent::EVENT_TYPE_ASK_USER_FOR_GOOGLE_RATINGS_WHATSAPP_MESSAGE_WAS_SENT,
10,
$jobseekerProfile->getId()
)) {
$this->platformEventService->eventHasOccurred(
PlatformEvent::EVENT_TYPE_ASK_USER_FOR_GOOGLE_RATINGS_WHATSAPP_MESSAGE_WAS_SENT,
$jobseekerProfile->getId()
);
$this->messageBus->dispatch(
new AskNewUserForGoogleRatingSymfonyMessage($event->getExtendedApplication())
);
}
}
}
$this
->integratedExternalPartnerCustomerService
->handleNeccessaryExternalApplications($event->getExtendedApplication());
} catch (Throwable $t) {
$this->logger->error(
sprintf(
"Error while handling onExtendedApplicationCreated symfony event for extended application '%s' for recurrent job '%s': '%s'",
$event->getExtendedApplication()->getId(),
$event->getExtendedApplication()->getRecurrentJob()?->getId(),
$t->getMessage()
),
['exception' => $t]
);
throw new Exception($t->getMessage(), $t->getCode(), $t);
}
}
public function onExtendedApplicationReadByJobofferer(
ExtendedApplicationReadByJoboffererEvent $event
): void {
/* @see ConversationMessageService::getUnreadMessagesCount — unread extended applications count as unread messages, too */
$joboffererUser = $event->getExtendedApplication()->getRecurrentJob()?->getJoboffererProfile()->getUser();
if (!is_null($joboffererUser)) {
$this->messageBus->dispatch(
new UpdateCachedUnreadConversationMessagesCountSymfonyMessage(
$joboffererUser
)
);
}
}
}