Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117757021
D2833.1775206794.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D2833.1775206794.diff
View Options
diff --git a/src/app/Policy/Greylist/Request.php b/src/app/Policy/Greylist/Request.php
--- a/src/app/Policy/Greylist/Request.php
+++ b/src/app/Policy/Greylist/Request.php
@@ -113,14 +113,6 @@
// FIXME: Shouldn't we bail-out (return early) if there's no $recipient?
// the following block is to maintain statistics and state ...
- $entries = Connect::where(
- [
- 'sender_domain' => $this->senderDomain,
- 'net_id' => $this->netID,
- 'net_type' => $this->netType
- ]
- )
- ->whereDate('updated_at', '>=', $this->timestamp->copy()->subDays(7));
// determine if the sender domain is a whitelist from this network
$this->whitelist = Whitelist::where(
@@ -131,6 +123,8 @@
]
)->first();
+ $cutoffDate = $this->timestamp->copy()->subDays(7);
+
if ($this->whitelist) {
if ($this->whitelist->updated_at < $this->timestamp->copy()->subMonthsWithoutOverflow(1)) {
$this->whitelist->delete();
@@ -138,17 +132,37 @@
$this->whitelist->updated_at = $this->timestamp;
$this->whitelist->save(['timestamps' => false]);
- $entries->update(
+ Connect::where(
[
- 'greylisting' => false,
- 'updated_at' => $this->timestamp
+ 'sender_domain' => $this->senderDomain,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType,
+ 'greylisting' => true
]
- );
+ )
+ ->whereDate('updated_at', '>=', $cutoffDate)
+ ->update(
+ [
+ 'greylisting' => false,
+ 'updated_at' => $this->timestamp
+ ]
+ );
return false;
}
} else {
- if ($entries->count() >= 5) {
+ $count = Connect::where(
+ [
+ 'sender_domain' => $this->senderDomain,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType
+ ]
+ )
+ ->whereDate('updated_at', '>=', $cutoffDate)
+ ->limit(5)->count();
+
+ // Automatically create a whitelist if we have at least 5 messages from the sender
+ if ($count >= 5) {
$this->whitelist = Whitelist::create(
[
'sender_domain' => $this->senderDomain,
@@ -159,12 +173,21 @@
]
);
- $entries->update(
+ Connect::where(
[
- 'greylisting' => false,
- 'updated_at' => $this->timestamp
+ 'sender_domain' => $this->senderDomain,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType,
+ 'greylisting' => true
]
- );
+ )
+ ->whereDate('updated_at', '>=', $cutoffDate)
+ ->update(
+ [
+ 'greylisting' => false,
+ 'updated_at' => $this->timestamp
+ ]
+ );
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 8:59 AM (18 h, 51 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823374
Default Alt Text
D2833.1775206794.diff (3 KB)
Attached To
Mode
D2833: Avoid large queries in greylist request
Attached
Detach File
Event Timeline