Merge pull request #4659 from nextcloud/fix/ignore-empty-email-contacts-menu
Do not show an email action for contacts with emtpy email addresses
This commit is contained in:
commit
121cb4bcfc
|
@ -52,6 +52,10 @@ class EMailProvider implements IProvider {
|
||||||
public function process(IEntry $entry) {
|
public function process(IEntry $entry) {
|
||||||
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
|
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
|
||||||
foreach ($entry->getEMailAddresses() as $address) {
|
foreach ($entry->getEMailAddresses() as $address) {
|
||||||
|
if (empty($address)) {
|
||||||
|
// Skip
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
|
$action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
|
||||||
$entry->addAction($action);
|
$entry->addAction($action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,4 +79,28 @@ class EMailproviderTest extends TestCase {
|
||||||
$this->provider->process($entry);
|
$this->provider->process($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessEmptyAddress() {
|
||||||
|
$entry = $this->createMock(IEntry::class);
|
||||||
|
$action = $this->createMock(ILinkAction::class);
|
||||||
|
$iconUrl = 'https://example.com/img/actions/icon.svg';
|
||||||
|
$this->urlGenerator->expects($this->once())
|
||||||
|
->method('imagePath')
|
||||||
|
->willReturn('img/actions/icon.svg');
|
||||||
|
$this->urlGenerator->expects($this->once())
|
||||||
|
->method('getAbsoluteURL')
|
||||||
|
->with('img/actions/icon.svg')
|
||||||
|
->willReturn($iconUrl);
|
||||||
|
$entry->expects($this->once())
|
||||||
|
->method('getEMailAddresses')
|
||||||
|
->willReturn([
|
||||||
|
'',
|
||||||
|
]);
|
||||||
|
$this->actionFactory->expects($this->never())
|
||||||
|
->method('newEMailAction');
|
||||||
|
$entry->expects($this->never())
|
||||||
|
->method('addAction');
|
||||||
|
|
||||||
|
$this->provider->process($entry);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue