Skip to content

Commit

Permalink
Merge branch 'release/37.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Oct 30, 2024
2 parents 45702da + ce0b455 commit 9719773
Show file tree
Hide file tree
Showing 17 changed files with 249 additions and 45 deletions.
Binary file modified .project/data/db.sql.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Fingerprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Fingerprint extends AbstractModel
protected string $domain = '';
protected string $userAgent = '';
protected string $site = '';
protected int $type = 0;
protected int $type = self::TYPE_FINGERPRINT;

public function __construct(string $domain = '', string $userAgent = '')
{
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/PagevisitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public function findLatestPagevisitsWithCompanies(FilterDto $filter): QueryResul
. $this->extendWhereClauseWithFilterRevenueClass($filter, 'c')
. $this->extendWhereClauseWithFilterBranchCode($filter)
. $this->extendWhereClauseWithFilterCategory($filter, 'c')
. ' group by c.uid'
. ' order by uid desc, pv.crdate desc'
. ' group by c.uid, pv.crdate'
. ' order by c.uid desc, pv.crdate desc'
. ' limit ' . $filter->getLimit();
$connection = DatabaseUtility::getConnectionForTable(Company::TABLE_NAME);
$identifiers = ArrayUtility::convertFetchedAllArrayToNumericArray(
Expand Down
17 changes: 11 additions & 6 deletions Classes/Domain/Service/Image/AbstractImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);
namespace In2code\Lux\Domain\Service\Image;

use Buchin\GoogleImageGrabber\GoogleImageGrabber;
use Buchin\Bing\Image;
use In2code\Lux\Utility\ConfigurationUtility;
use In2code\Lux\Utility\DateUtility;
use In2code\Lux\Utility\FileUtility;
Expand Down Expand Up @@ -53,19 +53,24 @@ protected function getDefaultUrl(string $url): string
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
*/
protected function getImageFromGoogle(string $url, string $searchTerm): string
protected function getImageFromBing(string $url, string $searchTerm): string
{
$configuration = [
'all',
'nogravatar',
];
if (empty($url) && class_exists(GoogleImageGrabber::class)) {
if (empty($url) && class_exists(Image::class)) {
if (in_array(ConfigurationUtility::getLeadImageFromExternalSourcesConfiguration(), $configuration)) {
try {
$images = GoogleImageGrabber::grab($searchTerm);
$imageScraper = new Image();
$images = $imageScraper->scrape($searchTerm, '', ['image_size' => 'small']);
foreach ($images as $image) {
if (!empty($image['url']) && FileUtility::isImageFile($image['url']) && $image['width'] > 25) {
$url = $image['url'];
if (
!empty($image['mediaurl'])
&& FileUtility::isImageFile($image['mediaurl'])
&& (int)$image['width'] > 25
) {
$url = $image['mediaurl'];
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Service/Image/CompanyImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct()
protected function buildImageUrl(): string
{
$url = '';
$url = $this->getImageFromGoogle($url, $this->arguments['company']->getTitle());
$url = $this->getImageFromBing($url, $this->arguments['company']->getTitle());
$url = $this->getDefaultUrl($url);
return $url;
}
Expand Down
20 changes: 14 additions & 6 deletions Classes/Domain/Service/Image/VisitorImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
declare(strict_types=1);
namespace In2code\Lux\Domain\Service\Image;

use In2code\Lux\Domain\Model\Visitor;
use In2code\Lux\Domain\Service\Provider\CustomerMail;
use In2code\Lux\Utility\ConfigurationUtility;
use In2code\Lux\Utility\EmailUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
Expand All @@ -16,8 +19,11 @@ class VisitorImageService extends AbstractImageService
public const CACHE_KEY = 'lux_visitor_imageurl';
protected int $size = 150;

public function __construct()
protected CustomerMail $customerMail;

public function __construct(CustomerMail $customerMail)
{
$this->customerMail = $customerMail;
$this->cacheInstance = GeneralUtility::makeInstance(CacheManager::class)->getCache(self::CACHE_KEY);
}

Expand All @@ -28,11 +34,13 @@ public function __construct()
*/
protected function buildImageUrl(): string
{
/** @var Visitor $visitor */
$visitor = $this->arguments['visitor'];
$url = '';
$url = $this->getImageUrlFromFrontenduser($url);
$url = $this->getImageUrlFromGravatar($url);
if ($this->arguments['visitor']->isIdentified()) {
$url = $this->getImageFromGoogle($url, $this->arguments['visitor']->getEmail());
if ($visitor->isIdentified() && $this->customerMail->isB2bEmail($visitor->getEmail())) {
$url = $this->getImageFromBing($url, EmailUtility::getDomainFromEmail($visitor->getEmail()));
}
$url = $this->getDefaultUrl($url);
return $url;
Expand All @@ -47,8 +55,8 @@ protected function getImageUrlFromFrontenduser(string $url): string
$imageService = GeneralUtility::makeInstance(ImageService::class);
$image = $imageService->getImage('', $file, false);
$processConfiguration = [
'width' => (string)$this->size . 'c',
'height' => (string)$this->size . 'c',
'width' => $this->size . 'c',
'height' => $this->size . 'c',
];
$processedImage = $imageService->applyProcessingInstructions($image, $processConfiguration);
$url = $imageService->getImageUri($processedImage, true);
Expand All @@ -67,7 +75,7 @@ protected function getImageUrlFromGravatar(string $url): string
{
$configuration = [
'all',
'nogoogle',
'nosearchengine',
];
if (empty($url) && $this->arguments['visitor']->isIdentified()) {
if (in_array(ConfigurationUtility::getLeadImageFromExternalSourcesConfiguration(), $configuration)) {
Expand Down
77 changes: 77 additions & 0 deletions Classes/Domain/Service/Provider/CustomerMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

declare(strict_types=1);
namespace In2code\Lux\Domain\Service\Provider;

/**
* Class CustomerMail
* this class can decide if an email belongs to a b2c or b2b contact
*/
class CustomerMail
{
protected AllowedMail $allowedMail;

protected array $b2cEmailDomains = [
'1und1.de',
'aok.de',
'aon.at',
'arcor.de',
'barmer.de',
'bluemail.ch',
'bluewin.ch',
'chello.at',
'dak.de',
'email.de',
'ewe.net',
'freenet.de',
'gmail.com',
'gmx.at',
'gmx.ch',
'gmx.de',
'gmx.net',
'googlemail.com',
'hotmail.com',
'hotmail.de',
'htp-tel.de',
'icloud.com',
'ikk-classic.de',
'kabelbw.de',
'live.com',
'mac.com',
'mail.de',
'me.com',
'mozmail.com',
'o2online.de',
'online.de',
'osnanet.de',
'ostfalia.de',
'outlook.com',
'outlook.de',
'posteo.de',
't-online.de',
'telekom.de',
'tk.de',
'versanet.de',
'vodafone.de',
'vodafonemail.de',
'web.de',
'yahoo.com',
'yahoo.de',
];

public function __construct(AllowedMail $allowedMail)
{
$this->allowedMail = $allowedMail;
}

public function isB2cEmail(string $email): bool
{
$domain = strtolower(substr(strrchr($email, '@'), 1));
return in_array($domain, $this->b2cEmailDomains) || $this->allowedMail->isEmailAllowed($email) === false;
}

public function isB2bEmail(string $email): bool
{
return $this->isB2cEmail($email) === false;
}
}
5 changes: 4 additions & 1 deletion Classes/Utility/ConfigurationUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ public static function isAnonymizeIpEnabled(): bool
}

/**
* @return string "all", "nogoogle", "nogravatar", "noexternal"
* @return string "all", "nosearchengine", "nogravatar", "noexternal"
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
*/
public static function getLeadImageFromExternalSourcesConfiguration(): string
{
$extensionConfig = self::getExtensionConfiguration();
if (array_key_exists('leadImageFromExternalSources', $extensionConfig)) {
if ($extensionConfig['leadImageFromExternalSources'] === 'nogoogle') {
$extensionConfig['leadImageFromExternalSources'] = 'nosearchengine';
}
return $extensionConfig['leadImageFromExternalSources'];
}
return 'all';
Expand Down
5 changes: 5 additions & 0 deletions Classes/Utility/EmailUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ public static function extendEmailReceiverArray(array $emails, string $receiverN
}
return $extendedArray;
}

public static function getDomainFromEmail(string $email): string
{
return strtolower(substr(strrchr($email, '@') ?: '', 1));
}
}
25 changes: 25 additions & 0 deletions Configuration/ContentSecurityPolicies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Directive;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationCollection;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationMode;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\SourceScheme;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\UriValue;
use TYPO3\CMS\Core\Type\Map;

return Map::fromEntries([
Scope::backend(),

new MutationCollection(
new Mutation(
MutationMode::Extend,
Directive::ImgSrc,
SourceScheme::data,
new UriValue('*'),
),
),
]);
6 changes: 6 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ services:
- name: event.listener
identifier: 'lux/preventReferenceIndex'

In2code\Lux\Domain\Service\Image\VisitorImageService:
public: true

In2code\Lux\Domain\Service\Provider\CustomerMail:
public: true

In2code\Lux\ViewHelpers\Lead\GetDateOfLatestPageVisitAndPageViewHelper:
public: true

Expand Down
Loading

0 comments on commit 9719773

Please sign in to comment.