diff options
-rw-r--r-- | lib/Address.php | 2 | ||||
-rw-r--r-- | lib/Service/AutoConfig/MxRecord.php | 2 | ||||
-rw-r--r-- | lib/Service/Avatar/FaviconSource.php | 1 | ||||
-rw-r--r-- | lib/Service/Avatar/GravatarSource.php | 5 | ||||
-rw-r--r-- | lib/Service/SetupService.php | 4 | ||||
-rw-r--r-- | tests/Integration/Service/MailTransmissionIntegrationTest.php | 1 | ||||
-rw-r--r-- | tests/Unit/Service/MailTransmissionTest.php | 10 |
7 files changed, 21 insertions, 4 deletions
diff --git a/lib/Address.php b/lib/Address.php index de2bb2785..8f82c8b32 100644 --- a/lib/Address.php +++ b/lib/Address.php @@ -52,7 +52,7 @@ class Address implements JsonSerializable { public static function fromRaw(string $label, string $email): self { $wrapped = new Horde_Mail_Rfc822_Address($email); // If no label is set we use the email - if ($label !== $email && $label !== null) { + if ($label !== $email) { $wrapped->personal = $label; } return new self($wrapped); diff --git a/lib/Service/AutoConfig/MxRecord.php b/lib/Service/AutoConfig/MxRecord.php index ccf2c6231..ceb93c33f 100644 --- a/lib/Service/AutoConfig/MxRecord.php +++ b/lib/Service/AutoConfig/MxRecord.php @@ -36,7 +36,7 @@ class MxRecord { /** * @param $host - * @return bool|array + * @return false|array */ public function query(string $host) { if (getmxrr($host, $mxRecords, $mxWeight) === false) { diff --git a/lib/Service/Avatar/FaviconSource.php b/lib/Service/Avatar/FaviconSource.php index a53f55ed2..eae238514 100644 --- a/lib/Service/Avatar/FaviconSource.php +++ b/lib/Service/Avatar/FaviconSource.php @@ -75,6 +75,7 @@ class FaviconSource implements IAvatarSource { return null; } + /** @var string $iconUrl */ $client = $this->clientService->newClient(); try { $response = $client->get($iconUrl); diff --git a/lib/Service/Avatar/GravatarSource.php b/lib/Service/Avatar/GravatarSource.php index 7288872c0..6aef4bda1 100644 --- a/lib/Service/Avatar/GravatarSource.php +++ b/lib/Service/Avatar/GravatarSource.php @@ -27,6 +27,8 @@ namespace OCA\Mail\Service\Avatar; use Exception; use OCA\Mail\Vendor\Gravatar\Gravatar; use OCP\Http\Client\IClientService; +use function is_resource; +use function stream_get_contents; class GravatarSource implements IAvatarSource { @@ -65,6 +67,9 @@ class GravatarSource implements IAvatarSource { // Don't save 0 byte images $body = $response->getBody(); + if (is_resource($body)) { + $body = stream_get_contents($body); + } if (strlen($body) === 0) { return null; } diff --git a/lib/Service/SetupService.php b/lib/Service/SetupService.php index 78fb6e094..0be5984bf 100644 --- a/lib/Service/SetupService.php +++ b/lib/Service/SetupService.php @@ -119,8 +119,8 @@ class SetupService { 'smtpPassword' => $smtpPassword ]); $newAccount->setUserId($uid); - $newAccount->setInboundPassword($this->crypto->encrypt($newAccount->getInboundPassword())); - $newAccount->setOutboundPassword($this->crypto->encrypt($newAccount->getOutboundPassword())); + $newAccount->setInboundPassword($this->crypto->encrypt($imapPassword)); + $newAccount->setOutboundPassword($this->crypto->encrypt($smtpPassword)); $account = new Account($newAccount); $this->logger->debug('Connecting to account {account}', ['account' => $newAccount->getEmail()]); diff --git a/tests/Integration/Service/MailTransmissionIntegrationTest.php b/tests/Integration/Service/MailTransmissionIntegrationTest.php index fad4b3f37..7d6f71362 100644 --- a/tests/Integration/Service/MailTransmissionIntegrationTest.php +++ b/tests/Integration/Service/MailTransmissionIntegrationTest.php @@ -76,6 +76,7 @@ class MailTransmissionIntegrationTest extends TestCase { $mapper = OC::$server->query(MailAccountMapper::class); $mailAccount = MailAccount::fromParams([ 'userId' => $this->user->getUID(), + 'name' => 'Test User', 'email' => 'user@domain.tld', 'inboundHost' => 'localhost', 'inboundPort' => '993', diff --git a/tests/Unit/Service/MailTransmissionTest.php b/tests/Unit/Service/MailTransmissionTest.php index 9525a3a26..4aeaf2cda 100644 --- a/tests/Unit/Service/MailTransmissionTest.php +++ b/tests/Unit/Service/MailTransmissionTest.php @@ -103,6 +103,8 @@ class MailTransmissionTest extends TestCase { /** @var Account|MockObject $account */ $account = $this->createMock(Account::class); $account->method('getMailAccount')->willReturn($mailAccount); + $account->method('getName')->willReturn('Test User'); + $account->method('getEMailAddress')->willReturn('test@user'); $messageData = NewMessageData::fromRequest($account, 'to@d.com', '', '', 'sub', 'bod'); $message = new Message(); $account->expects($this->once()) @@ -123,6 +125,8 @@ class MailTransmissionTest extends TestCase { /** @var Account|MockObject $account */ $account = $this->createMock(Account::class); $account->method('getMailAccount')->willReturn($mailAccount); + $account->method('getName')->willReturn('Test User'); + $account->method('getEMailAddress')->willReturn('test@user'); $alias = new Alias(); $alias->setAlias('a@d.com'); $messageData = NewMessageData::fromRequest($account, 'to@d.com', '', '', 'sub', 'bod'); @@ -151,6 +155,8 @@ class MailTransmissionTest extends TestCase { /** @var Account|MockObject $account */ $account = $this->createMock(Account::class); $account->method('getMailAccount')->willReturn($mailAccount); + $account->method('getName')->willReturn('Test User'); + $account->method('getEMailAddress')->willReturn('test@user'); $attachmenst = [ [ 'fileName' => 'cat.jpg', @@ -191,6 +197,8 @@ class MailTransmissionTest extends TestCase { /** @var Account|MockObject $account */ $account = $this->createMock(Account::class); $account->method('getMailAccount')->willReturn($mailAccount); + $account->method('getName')->willReturn('Test User'); + $account->method('getEMailAddress')->willReturn('test@user'); $messageData = NewMessageData::fromRequest($account, 'to@d.com', '', '', 'sub', 'bod'); $folderId = 'INBOX'; $repliedMessageUid = 321; @@ -217,6 +225,8 @@ class MailTransmissionTest extends TestCase { /** @var Account|MockObject $account */ $account = $this->createMock(Account::class); $account->method('getMailAccount')->willReturn($mailAccount); + $account->method('getName')->willReturn('Test User'); + $account->method('getEMailAddress')->willReturn('test@user'); $messageData = NewMessageData::fromRequest($account, 'to@d.com', '', '', 'sub', 'bod'); $message = new Message(); $account->expects($this->once()) |