Changeset View
Changeset View
Standalone View
Standalone View
src/app/Policy/Greylist/Request.php
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public function shouldDefer() | ||||
if (strpos($this->sender, '@') !== false) { | if (strpos($this->sender, '@') !== false) { | ||||
list($this->senderLocal, $this->senderDomain) = explode('@', $this->sender); | list($this->senderLocal, $this->senderDomain) = explode('@', $this->sender); | ||||
} | } | ||||
if (strlen($this->senderLocal) > 255) { | if (strlen($this->senderLocal) > 255) { | ||||
$this->senderLocal = substr($this->senderLocal, 0, 255); | $this->senderLocal = substr($this->senderLocal, 0, 255); | ||||
} | } | ||||
$entry = $this->findConnectsCollectionRecent()->orderBy('updated_at')->first(); | if (!$this->findConnectsCollectionRecent()->exist()) { | ||||
if (!$entry) { | |||||
// purge all entries to avoid a unique constraint violation. | // purge all entries to avoid a unique constraint violation. | ||||
$this->findConnectsCollection()->delete(); | $this->findConnectsCollection()->delete(); | ||||
$entry = Connect::create( | Connect::create( | ||||
[ | [ | ||||
'sender_local' => $this->senderLocal, | 'sender_local' => $this->senderLocal, | ||||
'sender_domain' => $this->senderDomain, | 'sender_domain' => $this->senderDomain, | ||||
'net_id' => $this->netID, | 'net_id' => $this->netID, | ||||
'net_type' => $this->netType, | 'net_type' => $this->netType, | ||||
'recipient_hash' => $this->recipientHash, | 'recipient_hash' => $this->recipientHash, | ||||
'recipient_id' => $this->recipientID, | 'recipient_id' => $this->recipientID, | ||||
'recipient_type' => $this->recipientType, | 'recipient_type' => $this->recipientType, | ||||
'connect_count' => 1, | 'connect_count' => 1, | ||||
'created_at' => $this->timestamp, | 'created_at' => $this->timestamp, | ||||
'updated_at' => $this->timestamp | 'updated_at' => $this->timestamp | ||||
] | ] | ||||
); | ); | ||||
//FIXME at this point we should be able to just bail out, no? | |||||
//An otherwise we don't have to create the entry and can just wait for it to be created at the end of the function? | |||||
} | } | ||||
// See if the recipient opted-out of the feature | // See if the recipient opted-out of the feature | ||||
$enabled = true; | $enabled = true; | ||||
if ($recipient) { | if ($recipient) { | ||||
$enabled = $recipient->getSetting('greylist_enabled') !== 'false'; | $enabled = $recipient->getSetting('greylist_enabled') !== 'false'; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |