Skip to content
Open

Dev #384

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ parameters:
env(PREFERENCEPAGE_SHOW_PRIVATE_LISTS): '0'
app.rest_api_base_url: '%%env(REST_API_BASE_URL)%%'
env(REST_API_BASE_URL): 'http://api.phplist.local/api/v2'
api_base_url: '%%env(API_BASE_URL)%%'
env(API_BASE_URL): 'http://api.phplist.local/'
app.frontend_base_url: '%%env(FRONT_END_BASE_URL)%%'
env(FRONT_END_BASE_URL): 'http://frontend.phplist.local'
parallel_use_with_phplist3: '%%env(parallel_use_with_phplist3)%%'
env(parallel_use_with_phplist3): '0'

# Email configuration
app.mailer_from: '%%env(MAILER_FROM)%%'
Expand All @@ -49,6 +53,8 @@ parameters:
env(SUBSCRIPTION_CONFIRMATION_URL): 'http://api.phplist.local/api/v2/subscription/confirm/'
app.password_reset_url: '%%env(PASSWORD_RESET_URL)%%'
env(PASSWORD_RESET_URL): 'https://example.com/reset/'
app.show_unsubscribe_link: '%%env(SHOW_UNSUBSCRIBELINK)%%'
env(SHOW_UNSUBSCRIBELINK): '1'

# bounce email settings
imap_bounce.email: '%%env(BOUNCE_EMAIL)%%'
Expand Down Expand Up @@ -145,10 +151,13 @@ parameters:
phplist.keep_forwarded_attributes: '%%env(KEEPFORWARDERATTRIBUTES)%%'
env(KEEPFORWARDERATTRIBUTES): '0'

phplist.upload_images_dir: '%%env(PHPLIST_UPLOADIMAGES_DIR)%%'
env(PHPLIST_UPLOADIMAGES_DIR): 'images'
phplist.editor_images_dir: '%%env(FCKIMAGES_DIR)%%'
env(FCKIMAGES_DIR): 'uploadimages'
phplist.upload_images_dir: '%%env(UPLOADIMAGES_DIR)%%'
env(UPLOADIMAGES_DIR): 'uploadimages'
phplist.uploads.allowed_mime_types: ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/svg+xml']
phplist.uploads.allowed_extensions: ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg']
phplist.uploads.max_size: '%%env(PHPLIST_UPLOADS_MAX_SIZE)%%'
env(PHPLIST_UPLOADS_MAX_SIZE): '5M'

phplist.public_schema: '%%env(PUBLIC_SCHEMA)%%'
env(PUBLIC_SCHEMA): 'https'
phplist.attachment_download_url: '%%env(PHPLIST_ATTACHMENT_DOWNLOAD_URL)%%'
Expand Down
2 changes: 2 additions & 0 deletions config/services/processor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ services:
PhpList\Core\Bounce\Service\Processor\UnidentifiedBounceReprocessor: ~

PhpList\Core\Bounce\Service\Processor\BounceDataProcessor: ~

PhpList\Core\Domain\Subscription\Service\SubscribePagePlaceholderProcessor: ~
25 changes: 24 additions & 1 deletion config/services/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ services:
autoconfigure: true
public: true

PhpList\Core\Domain\Subscription\Service\SubscribePageConfigMigrationService:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscribePageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\MessageProcessingPreparator:
autowire: true
autoconfigure: true
Expand Down Expand Up @@ -104,7 +112,7 @@ services:
autoconfigure: true

# External image caching/downloading helper used by TemplateImageEmbedder
PhpList\Core\Domain\Common\ExternalImageService:
PhpList\Core\Domain\Common\Service\ExternalImageService:
autowire: true
autoconfigure: true
arguments:
Expand Down Expand Up @@ -259,3 +267,18 @@ services:
$useManualTextPart: '%messaging.use_manual_text_part%'
$uploadImageDir: '%phplist.upload_images_dir%'
$publicSchema: '%phplist.public_schema%'

PhpList\Core\Domain\Common\Upload\Service\UploadService:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Common\Upload\Service\DirectoryListingService:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Common\Storage\UploadStorageInterface:
alias: PhpList\Core\Domain\Common\Storage\LocalUploadStorage

PhpList\Core\Domain\Common\Storage\LocalUploadStorage:
autowire: true
autoconfigure: true
8 changes: 8 additions & 0 deletions config/services/validators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ services:
PhpList\Core\Domain\Subscription\Validator\AttributeTypeValidator:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Common\Validator\UploadValidator:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Common\Validator\UploadDirectoryValidator:
autowire: true
autoconfigure: true
Binary file added public/power-phplist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions src/Domain/Analytics/Service/AnalyticsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,9 @@ public function getTopDomains(int $limit = 50, int $minSubscribers = 5): array

$domains = [];
foreach ($subscribers as $subscriber) {
$email = $subscriber->getEmail();
$domain = substr(strrchr($email, '@'), 1) ?: '';

if (!empty($domain)) {
if (!isset($domains[$domain])) {
$domains[$domain] = 0;
}
$domains[$domain]++;
$domain = $this->extractDomain($subscriber->getEmail());
if ($domain !== '') {
$domains[$domain] = ($domains[$domain] ?? 0) + 1;
}
}

Expand Down Expand Up @@ -287,12 +282,10 @@ private function calculateChange(float|int $current, float|int $previous): float
public function getDomainConfirmationStatistics(int $limit = 50): array
{
$domains = [];

$subscribers = $this->subscriberRepository->findAll();

foreach ($subscribers as $subscriber) {
$email = $subscriber->getEmail();
$domain = substr(strrchr($email, '@'), 1) ?: '';
$domain = $this->extractDomain($subscriber->getEmail());

if (!empty($domain)) {
if (!isset($domains[$domain])) {
Expand Down Expand Up @@ -358,6 +351,19 @@ public function getDomainConfirmationStatistics(int $limit = 50): array
];
}

private function extractDomain(string $email): ?string
{
$atPoint = strrchr($email, '@');

if ($atPoint === false) {
return null;
}

$domain = substr($atPoint, 1);

return $domain !== '' ? $domain : null;
}

private function formatStat(int $count, int $total): int|float
{
$percentage = $total > 0 ? ($count / $total) * 100 : 0;
Expand Down
9 changes: 9 additions & 0 deletions src/Domain/Common/Exception/InvalidUploadException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

class InvalidUploadException extends UploadException
{
}
9 changes: 9 additions & 0 deletions src/Domain/Common/Exception/MissingUploadException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

class MissingUploadException extends UploadException
{
}
9 changes: 9 additions & 0 deletions src/Domain/Common/Exception/StorageException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

class StorageException extends UploadException
{
}
9 changes: 9 additions & 0 deletions src/Domain/Common/Exception/UnsupportedExtensionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

class UnsupportedExtensionException extends UploadException
{
}
9 changes: 9 additions & 0 deletions src/Domain/Common/Exception/UnsupportedMimeTypeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

class UnsupportedMimeTypeException extends UploadException
{
}
11 changes: 11 additions & 0 deletions src/Domain/Common/Exception/UploadException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

use RuntimeException;

class UploadException extends RuntimeException
{
}
9 changes: 9 additions & 0 deletions src/Domain/Common/Exception/UploadTooLargeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Exception;

class UploadTooLargeException extends UploadException
{
}
42 changes: 42 additions & 0 deletions src/Domain/Common/Model/StoredFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Model;

class StoredFile
{
public function __construct(
private readonly string $filename,
private readonly string $path,
private readonly string $mimeType,
private readonly int $size,
private readonly string $extension,
) {
}

public function getFilename(): string
{
return $this->filename;
}

public function getPath(): string
{
return $this->path;
}

public function getMimeType(): string
{
return $this->mimeType;
}

public function getSize(): int
{
return $this->size;
}

public function getExtension(): string
{
return $this->extension;
}
}
42 changes: 42 additions & 0 deletions src/Domain/Common/Model/UploadResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Common\Model;

class UploadResult
{
public function __construct(
private readonly string $filename,
private readonly string $url,
private readonly string $mimeType,
private readonly int $size,
private readonly string $extension,
) {
}

public function getFilename(): string
{
return $this->filename;
}

public function getUrl(): string
{
return $this->url;
}

public function getMimeType(): string
{
return $this->mimeType;
}

public function getSize(): int
{
return $this->size;
}

public function getExtension(): string
{
return $this->extension;
}
}
Loading
Loading