-
Notifications
You must be signed in to change notification settings - Fork 30
ref: email sending #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ref: email sending #388
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2354bdb
ref: replace findByIdAndStatus with tryClaimForProcessing in Campaign…
tatevikg1 d84ad25
feat: add exclude list functionality to CampaignProcessorMessageHandler
tatevikg1 8167417
feat: implement domain rate limiting functionality
tatevikg1 023d26e
feat: implement domain rate limiting
tatevikg1 0b8d113
feat: getStuckCampaigns
tatevikg1 ba33ad2
feat: enhance exclusion logic for campaign subscribers
tatevikg1 69e8c33
fix: getStatus method to handle null status
tatevikg1 913e823
feat: update guidelines for atomic conditional-UPDATE reservation pat…
tatevikg1 83bc8bd
feat: add stuck campaign threshold to tryClaimForProcessing method
tatevikg1 cd3f6b2
feat: implement atomic reset for blocked count in DomainThrottleState…
tatevikg1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| PHPLIST_DATABASE_DRIVER=pdo_sqlite | ||
| PHPLIST_DATABASE_PATH=:memory: | ||
| SEARCH_TRANSPORT_DSN=sync:// | ||
| ELASTICSEARCH_ENABLED=false | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PhpList\Core\Domain\Messaging\Model; | ||
|
|
||
| use Doctrine\ORM\Mapping as ORM; | ||
| use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel; | ||
| use PhpList\Core\Domain\Messaging\Repository\DomainThrottleStateRepository; | ||
|
|
||
| /** | ||
| * Per-domain send counters for a single fixed throttle window, persisted so that | ||
| * DomainRateLimiter enforces DOMAIN_BATCH_SIZE/DOMAIN_BATCH_PERIOD consistently across | ||
| * concurrent queue-processing workers instead of each worker keeping its own count. | ||
| * Rows are read/written exclusively via DomainThrottleStateRepository's atomic | ||
| * UPDATE/INSERT statements, not through the entity manager's persist/flush. | ||
| */ | ||
| #[ORM\Entity(repositoryClass: DomainThrottleStateRepository::class)] | ||
| #[ORM\Table(name: 'domain_throttle')] | ||
| class DomainThrottleState implements DomainModel | ||
| { | ||
| #[ORM\Id] | ||
| #[ORM\Column(name: 'domain', type: 'string', length: 255)] | ||
| private string $domain; | ||
|
|
||
| #[ORM\Column(name: 'window_start', type: 'integer')] | ||
| private int $windowStart; | ||
|
|
||
| #[ORM\Column(name: 'sent_count', type: 'integer')] | ||
| private int $sentCount; | ||
|
|
||
| #[ORM\Column(name: 'blocked_count', type: 'integer')] | ||
| private int $blockedCount; | ||
|
|
||
| public function __construct(string $domain, int $windowStart, int $sentCount = 0, int $blockedCount = 0) | ||
| { | ||
| $this->domain = $domain; | ||
| $this->windowStart = $windowStart; | ||
| $this->sentCount = $sentCount; | ||
| $this->blockedCount = $blockedCount; | ||
| } | ||
|
|
||
| public function getDomain(): string | ||
| { | ||
| return $this->domain; | ||
| } | ||
|
|
||
| public function getWindowStart(): int | ||
| { | ||
| return $this->windowStart; | ||
| } | ||
|
|
||
| public function getSentCount(): int | ||
| { | ||
| return $this->sentCount; | ||
| } | ||
|
|
||
| public function getBlockedCount(): int | ||
| { | ||
| return $this->blockedCount; | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/Domain/Messaging/Model/Dto/DomainThrottleReservation.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PhpList\Core\Domain\Messaging\Model\Dto; | ||
|
|
||
| /** | ||
| * Outcome of an atomic slot reservation attempt in DomainThrottleStateRepository. | ||
| */ | ||
| final class DomainThrottleReservation | ||
| { | ||
| public function __construct( | ||
| public readonly bool $allowed, | ||
| public readonly int $blockedAttempts = 0, | ||
| ) { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PhpList\Core\Domain\Messaging\Model\Dto; | ||
|
|
||
| /** | ||
| * Outcome of DomainRateLimiter::attemptSend() for a single recipient. | ||
| */ | ||
| final class DomainThrottleResult | ||
| { | ||
| public function __construct( | ||
| public readonly bool $allowed, | ||
| public readonly ?string $domain, | ||
| public readonly int $blockedAttempts = 0, | ||
| public readonly bool $backoffApplied = false, | ||
| public readonly int $backoffSeconds = 0, | ||
| ) { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: phpList/core
Length of output: 311
🏁 Script executed:
Repository: phpList/core
Length of output: 26200
🏁 Script executed:
Repository: phpList/core
Length of output: 50368
Handle nullable
UserMessagestatuses before comparing them.When an existing
UserMessagehas aNULLstatus,markExcludedSubscribers()callsUserMessageStatus::from(null)throughgetStatus(). This can throw aTypeErrorand abort the campaign. MakegetStatus()null-safe, then define whetherNULLmeans “preserve” or should be treated asTodo.🤖 Prompt for AI Agents