just log double message IDs, don't discard the email
This commit is contained in:
parent
e2b736d0a9
commit
3eaaf716e9
2 changed files with 13 additions and 8 deletions
|
@ -143,7 +143,6 @@ class Emailer
|
||||||
}
|
}
|
||||||
if ($countMessageId > 0) {
|
if ($countMessageId > 0) {
|
||||||
$this->logger->warning('More than one Message-ID found - RFC violation', ['email' => $email]);
|
$this->logger->warning('More than one Message-ID found - RFC violation', ['email' => $email]);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$email_textonly = false;
|
$email_textonly = false;
|
||||||
|
|
|
@ -74,7 +74,7 @@ class EMailerTest extends MockedTest
|
||||||
$testEmail = $builder
|
$testEmail = $builder
|
||||||
->withRecipient('recipient@friendica.local')
|
->withRecipient('recipient@friendica.local')
|
||||||
->withMessage('Test Subject', "Test Message<b>Bold</b>", 'Test Text')
|
->withMessage('Test Subject', "Test Message<b>Bold</b>", 'Test Text')
|
||||||
->withSender('Sender', 'sender@friendica.loca')
|
->withSender('Sender', 'sender@friendica.local')
|
||||||
->forUser(['uid' => 1])
|
->forUser(['uid' => 1])
|
||||||
->addHeader('Message-ID', 'first Id')
|
->addHeader('Message-ID', 'first Id')
|
||||||
->build(true);
|
->build(true);
|
||||||
|
@ -87,7 +87,7 @@ class EMailerTest extends MockedTest
|
||||||
$this->assertContains("X-Friendica-Platform : Friendica", EmailerSpy::$MAIL_DATA['headers']);
|
$this->assertContains("X-Friendica-Platform : Friendica", EmailerSpy::$MAIL_DATA['headers']);
|
||||||
$this->assertContains("List-ID : <notification.friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
|
$this->assertContains("List-ID : <notification.friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
|
||||||
$this->assertContains("List-Archive : <http://friendica.local/notifications/system>", EmailerSpy::$MAIL_DATA['headers']);
|
$this->assertContains("List-Archive : <http://friendica.local/notifications/system>", EmailerSpy::$MAIL_DATA['headers']);
|
||||||
$this->assertContains("Reply-To: Sender <sender@friendica.loca>", EmailerSpy::$MAIL_DATA['headers']);
|
$this->assertContains("Reply-To: Sender <sender@friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
|
||||||
$this->assertContains("MIME-Version: 1.0", EmailerSpy::$MAIL_DATA['headers']);
|
$this->assertContains("MIME-Version: 1.0", EmailerSpy::$MAIL_DATA['headers']);
|
||||||
// Base64 "Test Text"
|
// Base64 "Test Text"
|
||||||
$this->assertContains(chunk_split(base64_encode('Test Text')), EmailerSpy::$MAIL_DATA['body']);
|
$this->assertContains(chunk_split(base64_encode('Test Text')), EmailerSpy::$MAIL_DATA['body']);
|
||||||
|
@ -98,12 +98,17 @@ class EMailerTest extends MockedTest
|
||||||
$this->assertEquals("-f sender@friendica.local", EmailerSpy::$MAIL_DATA['parameters']);
|
$this->assertEquals("-f sender@friendica.local", EmailerSpy::$MAIL_DATA['parameters']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrongReturnTwoMessageIds()
|
public function testTwoMessageIds()
|
||||||
{
|
{
|
||||||
/** @var IEmail $returnMail */
|
$this->pConfig->shouldReceive('get')->withArgs(['1', 'system', 'email_textonly'])->andReturn(false)->once();
|
||||||
$returnMail = null;
|
|
||||||
|
|
||||||
$this->mockHookCallAll('emailer_send_prepare', $returnMail);
|
/** @var IEmail $preparedEmail */
|
||||||
|
$preparedEmail = null;
|
||||||
|
/** @var IEmail $sentEMail */
|
||||||
|
$sentEMail = null;
|
||||||
|
|
||||||
|
$this->mockHookCallAll('emailer_send_prepare', $preparedEmail);
|
||||||
|
$this->mockHookCallAll('emailer_send', $sentEMail);
|
||||||
|
|
||||||
$builder = new SampleMailBuilder($this->l10n, $this->baseUrl, $this->config, new NullLogger());
|
$builder = new SampleMailBuilder($this->l10n, $this->baseUrl, $this->config, new NullLogger());
|
||||||
|
|
||||||
|
@ -118,7 +123,8 @@ class EMailerTest extends MockedTest
|
||||||
|
|
||||||
$emailer = new EmailerSpy($this->config, $this->pConfig, $this->baseUrl, new NullLogger(), $this->l10n);
|
$emailer = new EmailerSpy($this->config, $this->pConfig, $this->baseUrl, new NullLogger(), $this->l10n);
|
||||||
|
|
||||||
$this->assertFalse($emailer->send($testEmail));
|
// even in case there are two message ids, send the mail anyway
|
||||||
|
$this->assertTrue($emailer->send($testEmail));
|
||||||
|
|
||||||
// check case sensitive key problem
|
// check case sensitive key problem
|
||||||
$this->assertArrayHasKey('Message-ID', $testEmail->getAdditionalMailHeader());
|
$this->assertArrayHasKey('Message-ID', $testEmail->getAdditionalMailHeader());
|
||||||
|
|
Loading…
Reference in a new issue