em->getRepository(\Mautic\LeadBundle\Entity\Lead::class); $lead = $repo->getLeadByEmail($notification); return $this->doNotContact->addDncForContact($lead->getId(), 'notification', DoNotContact::UNSUBSCRIBED); } public function getHeaderScript() { if ($this->hasScript()) { return 'MauticJS.insertScript(\'https://cdn.onesignal.com/sdks/OneSignalSDK.js\'); var OneSignal = OneSignal || [];'; } } public function getScript() { if ($this->hasScript()) { $integration = $this->integrationHelper->getIntegrationObject('OneSignal'); if (!$integration || false === $integration->getIntegrationSettings()->getIsPublished()) { return; } $settings = $integration->getIntegrationSettings(); $keys = $integration->getDecryptedApiKeys(); $supported = $settings->getSupportedFeatures(); $featureSettings = $settings->getFeatureSettings(); $appId = $keys['app_id']; $safariWebId = $keys['safari_web_id']; $welcomenotificationEnabled = in_array('welcome_notification_enabled', $supported); $notificationSubdomainName = $featureSettings['subdomain_name']; $leadAssociationUrl = $this->router->generate( 'mautic_subscribe_notification', [], UrlGeneratorInterface::ABSOLUTE_URL ); $welcomenotificationText = ''; if (!$welcomenotificationEnabled) { $welcomenotificationText = 'welcomeNotification: { "disable": true },'; } $server = $this->requestStack->getCurrentRequest()->server; $https = ('https' == parse_url($server->get('HTTP_REFERER'), PHP_URL_SCHEME)) ? true : false; $subdomainName = ''; if (!$https && $notificationSubdomainName) { $subdomainName = 'subdomainName: "'.$notificationSubdomainName.'", httpPermissionRequest: { enable: true, useCustomModal: true },'; } $oneSignalInit = <<requestStack->getCurrentRequest()->server; $cookies = $this->requestStack->getCurrentRequest()->cookies; // already exist if ($cookies->get('mtc_osid')) { return false; } if (!str_contains($server->get('HTTP_REFERER'), $this->coreParametersHelper->get('site_url'))) { $landingPage = false; } $integration = $this->integrationHelper->getIntegrationObject('OneSignal'); if (!$integration || false === $integration->getIntegrationSettings()->getIsPublished()) { return false; } $supportedFeatures = $integration->getIntegrationSettings()->getSupportedFeatures(); // disable on Landing pages if (true === $landingPage && !in_array('landing_page_enabled', $supportedFeatures)) { return false; } // disable on Landing pages if (false === $landingPage && !in_array('tracking_page_enabled', $supportedFeatures)) { return false; } return true; } }