Skip to content

Commit dc99df1

Browse files
TatevikGrtatevikg1
andauthored
Bounce processing command (#355)
* BounceManager * Add bounce email * Move to the processor dir * SendProcess lock service * ClientIp + SystemInfo * ProcessBouncesCommand * ProcessBouncesCommand all methods * BounceProcessingService * AdvancedBounceRulesProcessor * UnidentifiedBounceReprocessor * ConsecutiveBounceHandler * Refactor * BounceDataProcessor * ClientFactory + refactor * BounceProcessorPass * Register services + phpstan fix * PhpMd * PhpMd CyclomaticComplexity * PhpCodeSniffer * Tests * Refactor * Add tests * More tests * Fix tests --------- Co-authored-by: Tatevik <tatevikg1@gmail.com>
1 parent 9d0c1db commit dc99df1

File tree

95 files changed

+5884
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+5884
-284
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
"symfony/sendgrid-mailer": "^6.4",
6969
"symfony/twig-bundle": "^6.4",
7070
"symfony/messenger": "^6.4",
71-
"symfony/lock": "^6.4"
71+
"symfony/lock": "^6.4",
72+
"webklex/php-imap": "^6.2",
73+
"ext-imap": "*"
7274
},
7375
"require-dev": {
7476
"phpunit/phpunit": "^9.5",

config/PHPMD/rules.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<!-- rules from the "naming" rule set -->
5252
<rule ref="rulesets/naming.xml/ShortVariable">
5353
<properties>
54-
<property name="exceptions" value="id,ip,cc"/>
54+
<property name="exceptions" value="id,ip,cc,io"/>
5555
</properties>
5656
</rule>
5757
<rule ref="rulesets/naming.xml/LongVariable">

config/PhpCodeSniffer/ruleset.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<!-- Classes -->
1616
<rule ref="Generic.Classes.DuplicateClassName"/>
1717
<rule ref="Squiz.Classes.ClassFileName"/>
18-
<rule ref="Squiz.Classes.DuplicateProperty"/>
1918
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
2019
<rule ref="Squiz.Classes.SelfMemberReference"/>
2120

@@ -41,9 +40,6 @@
4140
<!-- Control structures -->
4241
<rule ref="PEAR.ControlStructures.ControlSignature"/>
4342

44-
<!-- Debug -->
45-
<rule ref="Generic.Debug.ClosureLinter"/>
46-
4743
<!-- Files -->
4844
<rule ref="Generic.Files.OneClassPerFile"/>
4945
<rule ref="Generic.Files.OneInterfacePerFile"/>
@@ -54,7 +50,6 @@
5450
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
5551

5652
<!-- Functions -->
57-
<rule ref="Generic.Functions.CallTimePassByReference"/>
5853
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
5954
<rule ref="Squiz.Functions.GlobalFunction"/>
6055

@@ -66,9 +61,6 @@
6661
<rule ref="Generic.NamingConventions.ConstructorName"/>
6762
<rule ref="PEAR.NamingConventions.ValidClassName"/>
6863

69-
<!-- Objects -->
70-
<rule ref="Squiz.Objects.ObjectMemberComma"/>
71-
7264
<!-- Operators -->
7365
<rule ref="Squiz.Operators.IncrementDecrementUsage"/>
7466
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
@@ -110,6 +102,5 @@
110102
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
111103
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
112104
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
113-
<rule ref="Squiz.WhiteSpace.PropertyLabelSpacing"/>
114105
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
115106
</ruleset>

config/parameters.yml.dist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ parameters:
3232
app.password_reset_url: '%%env(PASSWORD_RESET_URL)%%'
3333
env(PASSWORD_RESET_URL): 'https://example.com/reset/'
3434

35+
# bounce email settings
36+
imap_bounce.email: '%%env(BOUNCE_EMAIL)%%'
37+
env(BOUNCE_EMAIL): 'bounce@phplist.com'
38+
imap_bounce.password: '%%env(BOUNCE_IMAP_PASS)%%'
39+
env(BOUNCE_IMAP_PASS): 'bounce@phplist.com'
40+
imap_bounce.host: '%%env(BOUNCE_IMAP_HOST)%%'
41+
env(BOUNCE_IMAP_HOST): 'imap.phplist.com'
42+
imap_bounce.port: '%%env(BOUNCE_IMAP_PORT)%%'
43+
env(BOUNCE_IMAP_PORT): '993'
44+
imap_bounce.encryption: '%%env(BOUNCE_IMAP_ENCRYPTION)%%'
45+
env(BOUNCE_IMAP_ENCRYPTION): 'ssl'
46+
imap_bounce.mailbox: '%%env(BOUNCE_IMAP_MAILBOX)%%'
47+
env(BOUNCE_IMAP_MAILBOX): '/var/spool/mail/bounces'
48+
imap_bounce.mailbox_name: '%%env(BOUNCE_IMAP_MAILBOX_NAME)%%'
49+
env(BOUNCE_IMAP_MAILBOX_NAME): 'INBOX,ONE_MORE'
50+
imap_bounce.protocol: '%%env(BOUNCE_IMAP_PROTOCOL)%%'
51+
env(BOUNCE_IMAP_PROTOCOL): 'imap'
52+
imap_bounce.unsubscribe_threshold: '%%env(BOUNCE_IMAP_UNSUBSCRIBE_THRESHOLD)%%'
53+
env(BOUNCE_IMAP_UNSUBSCRIBE_THRESHOLD): '5'
54+
imap_bounce.blacklist_threshold: '%%env(BOUNCE_IMAP_BLACKLIST_THRESHOLD)%%'
55+
env(BOUNCE_IMAP_BLACKLIST_THRESHOLD): '3'
56+
imap_bounce.purge: '%%env(BOUNCE_IMAP_PURGE)%%'
57+
env(BOUNCE_IMAP_PURGE): '0'
58+
imap_bounce.purge_unprocessed: '%%env(BOUNCE_IMAP_PURGE_UNPROCESSED)%%'
59+
env(BOUNCE_IMAP_PURGE_UNPROCESSED): '0'
60+
3561
# Messenger configuration for asynchronous processing
3662
app.messenger_transport_dsn: '%%env(MESSENGER_TRANSPORT_DSN)%%'
3763
env(MESSENGER_TRANSPORT_DSN): 'doctrine://default?auto_setup=true'

config/services.yml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
imports:
2-
- { resource: 'services/*.yml' }
2+
- { resource: 'services/*.yml' }
33

44
services:
5-
_defaults:
6-
autowire: true
7-
autoconfigure: true
8-
public: false
9-
10-
PhpList\Core\Core\ConfigProvider:
11-
arguments:
12-
$config: '%app.config%'
13-
14-
PhpList\Core\Core\ApplicationStructure:
15-
public: true
16-
17-
PhpList\Core\Security\Authentication:
18-
public: true
19-
20-
PhpList\Core\Security\HashGenerator:
21-
public: true
22-
23-
PhpList\Core\Routing\ExtraLoader:
24-
tags: [routing.loader]
25-
26-
PhpList\Core\Domain\Common\Repository\AbstractRepository:
27-
abstract: true
28-
autowire: true
29-
autoconfigure: false
30-
public: true
31-
factory: ['@doctrine.orm.entity_manager', getRepository]
32-
33-
# controllers are imported separately to make sure they're public
34-
# and have a tag that allows actions to type-hint services
35-
PhpList\Core\EmptyStartPageBundle\Controller\:
36-
resource: '../src/EmptyStartPageBundle/Controller'
37-
public: true
38-
tags: [controller.service_arguments]
39-
40-
doctrine.orm.metadata.annotation_reader:
41-
alias: doctrine.annotation_reader
42-
43-
doctrine.annotation_reader:
44-
class: Doctrine\Common\Annotations\AnnotationReader
45-
autowire: true
46-
47-
doctrine.orm.default_annotation_metadata_driver:
48-
class: Doctrine\ORM\Mapping\Driver\AnnotationDriver
49-
arguments:
50-
- '@annotation_reader'
51-
- '%kernel.project_dir%/src/Domain/Model/'
5+
_defaults:
6+
autowire: true
7+
autoconfigure: true
8+
public: false
9+
10+
PhpList\Core\Core\ConfigProvider:
11+
arguments:
12+
$config: '%app.config%'
13+
14+
PhpList\Core\Core\ApplicationStructure:
15+
public: true
16+
17+
PhpList\Core\Security\Authentication:
18+
public: true
19+
20+
PhpList\Core\Security\HashGenerator:
21+
public: true
22+
23+
PhpList\Core\Routing\ExtraLoader:
24+
tags: [routing.loader]
25+
26+
PhpList\Core\Domain\Common\Repository\AbstractRepository:
27+
abstract: true
28+
autowire: true
29+
autoconfigure: false
30+
public: true
31+
factory: ['@doctrine.orm.entity_manager', getRepository]
32+
33+
# controllers are imported separately to make sure they're public
34+
# and have a tag that allows actions to type-hint services
35+
PhpList\Core\EmptyStartPageBundle\Controller\:
36+
resource: '../src/EmptyStartPageBundle/Controller'
37+
public: true
38+
tags: [controller.service_arguments]
39+
40+
doctrine.orm.metadata.annotation_reader:
41+
alias: doctrine.annotation_reader
42+
43+
doctrine.annotation_reader:
44+
class: Doctrine\Common\Annotations\AnnotationReader
45+
autowire: true
46+
47+
doctrine.orm.default_annotation_metadata_driver:
48+
class: Doctrine\ORM\Mapping\Driver\AnnotationDriver
49+
arguments:
50+
- '@annotation_reader'
51+
- '%kernel.project_dir%/src/Domain/Model/'

config/services/builders.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ services:
2020
autowire: true
2121
autoconfigure: true
2222

23-
PhpListPhpList\Core\Domain\Messaging\Service\Builder\MessageOptionsBuilder:
23+
PhpList\Core\Domain\Messaging\Service\Builder\MessageOptionsBuilder:
2424
autowire: true
2525
autoconfigure: true

config/services/commands.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ services:
1111
PhpList\Core\Domain\Identity\Command\:
1212
resource: '../../src/Domain/Identity/Command'
1313
tags: ['console.command']
14+
15+
PhpList\Core\Domain\Messaging\Command\ProcessBouncesCommand:
16+
arguments:
17+
$protocolProcessors: !tagged_iterator 'phplist.bounce_protocol_processor'

config/services/managers.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,22 @@ services:
7272
autowire: true
7373
autoconfigure: true
7474

75+
PhpList\Core\Domain\Messaging\Service\Manager\BounceManager:
76+
autowire: true
77+
autoconfigure: true
78+
7579
PhpList\Core\Domain\Messaging\Service\Manager\ListMessageManager:
7680
autowire: true
7781
autoconfigure: true
7882

7983
PhpList\Core\Domain\Configuration\Service\Manager\ConfigManager:
8084
autowire: true
8185
autoconfigure: true
86+
87+
PhpList\Core\Domain\Messaging\Service\Manager\BounceRuleManager:
88+
autowire: true
89+
autoconfigure: true
90+
91+
PhpList\Core\Domain\Messaging\Service\Manager\SendProcessManager:
92+
autowire: true
93+
autoconfigure: true

config/services/processor.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: false
6+
7+
PhpList\Core\Domain\Messaging\Service\Processor\PopBounceProcessor:
8+
arguments:
9+
$host: '%imap_bounce.host%'
10+
$port: '%imap_bounce.port%'
11+
$mailboxNames: '%imap_bounce.mailbox_name%'
12+
tags: ['phplist.bounce_protocol_processor']
13+
14+
PhpList\Core\Domain\Messaging\Service\Processor\MboxBounceProcessor:
15+
tags: ['phplist.bounce_protocol_processor']
16+
17+
PhpList\Core\Domain\Messaging\Service\Processor\AdvancedBounceRulesProcessor: ~
18+
19+
PhpList\Core\Domain\Messaging\Service\Processor\UnidentifiedBounceReprocessor: ~
20+
21+
PhpList\Core\Domain\Messaging\Service\Processor\BounceDataProcessor: ~

config/services/providers.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ services:
22
PhpList\Core\Domain\Subscription\Service\Provider\SubscriberProvider:
33
autowire: true
44
autoconfigure: true
5+
6+
PhpList\Core\Domain\Messaging\Service\Provider\BounceActionProvider:
7+
autowire: true
8+
autoconfigure: true

0 commit comments

Comments
 (0)