diff --git a/lib/Service/AutoCompletion/AutoCompleteService.php b/lib/Service/AutoCompletion/AutoCompleteService.php
index 321a72c4b9..becbdaca05 100644
--- a/lib/Service/AutoCompletion/AutoCompleteService.php
+++ b/lib/Service/AutoCompletion/AutoCompleteService.php
@@ -41,6 +41,7 @@ public function findMatches(string $userId, string $term): array {
'id' => $address->getId(),
'label' => $address->getDisplayName(),
'email' => $address->getEmail(),
+ 'source' => 'collector',
];
}, $fromCollector);
diff --git a/lib/Service/ContactsIntegration.php b/lib/Service/ContactsIntegration.php
index 4a976b452d..97410a85ff 100644
--- a/lib/Service/ContactsIntegration.php
+++ b/lib/Service/ContactsIntegration.php
@@ -127,9 +127,10 @@ public function getMatchingRecipient(string $userId, string $term): array {
$receivers[] = [
'id' => $id,
// Show full name if possible or fall back to email
- 'label' => (empty($fn) ? $e : "$fn ($e)"),
+ 'label' => $fn,
'email' => $e,
'photo' => $photo,
+ 'source' => 'contacts',
];
}
}
diff --git a/lib/Service/GroupsIntegration.php b/lib/Service/GroupsIntegration.php
index f78d802930..04c831a607 100644
--- a/lib/Service/GroupsIntegration.php
+++ b/lib/Service/GroupsIntegration.php
@@ -52,6 +52,7 @@ public function getMatchingGroups(string $term): array {
'label' => $g['name'] . ' (' . $gs->getNamespace() . ')',
'email' => $gid,
'photo' => null,
+ 'source' => 'groups',
];
}
}
diff --git a/src/components/Composer.vue b/src/components/Composer.vue
index 2a71c38977..94d9ac646f 100644
--- a/src/components/Composer.vue
+++ b/src/components/Composer.vue
@@ -84,7 +84,7 @@
@@ -137,7 +137,7 @@
@@ -190,7 +190,7 @@
@@ -1422,15 +1422,24 @@ export default {
},
/**
- * Use the email address as subname if we have label
+ * Return the subname for recipient suggestion.
+ *
+ * Empty if label and email are the same or
+ * if the suggestion is a group.
*
* @param {{email: string, label: string}} option
* @return string
*/
- showEmailAsSubname(option) {
- return (option.label === option.email)
- ? ''
- : option.email
+ getSubnameForRecipient(option) {
+ if (option.source && option.source === 'groups') {
+ return ''
+ }
+
+ if (option.label === option.email) {
+ return ''
+ }
+
+ return option.email
},
},
}
diff --git a/tests/Unit/Service/Autocompletion/AutoCompleteServiceTest.php b/tests/Unit/Service/Autocompletion/AutoCompleteServiceTest.php
index ea5b55be62..c08d748a2f 100644
--- a/tests/Unit/Service/Autocompletion/AutoCompleteServiceTest.php
+++ b/tests/Unit/Service/Autocompletion/AutoCompleteServiceTest.php
@@ -37,8 +37,8 @@ public function testFindMatches() {
$term = 'jo';
$contactsResult = [
- ['id' => 12, 'label' => '"john doe" ', 'email' => 'john@doe.cz'],
- ['id' => 13, 'label' => '"joe doe" ', 'email' => 'joe@doe.se'],
+ ['id' => 12, 'label' => '"john doe" ', 'email' => 'john@doe.cz', 'source' => 'contacts'],
+ ['id' => 13, 'label' => '"joe doe" ', 'email' => 'joe@doe.se', 'source' => 'contacts'],
];
$john = new CollectedAddress();
$john->setId(1234);
@@ -50,7 +50,7 @@ public function testFindMatches() {
];
$groupsResult = [
- ['id' => 20, 'label' => 'Journalists', 'email' => 'Journalists']
+ ['id' => 20, 'label' => 'Journalists', 'email' => 'Journalists', 'source' => 'groups']
];
$this->contactsIntegration->expects($this->once())
@@ -72,10 +72,10 @@ public function testFindMatches() {
$response = $this->service->findMatches('testuser', $term);
$expected = [
- ['id' => 12, 'label' => '"john doe" ', 'email' => 'john@doe.cz'],
- ['id' => 13, 'label' => '"joe doe" ', 'email' => 'joe@doe.se'],
- ['id' => 1234, 'label' => 'John Doe', 'email' => 'john@doe.com'],
- ['id' => 20, 'label' => 'Journalists', 'email' => 'Journalists'],
+ ['id' => 12, 'label' => '"john doe" ', 'email' => 'john@doe.cz', 'source' => 'contacts'],
+ ['id' => 13, 'label' => '"joe doe" ', 'email' => 'joe@doe.se', 'source' => 'contacts'],
+ ['id' => 1234, 'label' => 'John Doe', 'email' => 'john@doe.com', 'source' => 'collector'],
+ ['id' => 20, 'label' => 'Journalists', 'email' => 'Journalists', 'source' => 'groups'],
];
$this->assertEquals($expected, $response);
}
diff --git a/tests/Unit/Service/GroupsIntegrationTest.php b/tests/Unit/Service/GroupsIntegrationTest.php
index 3cd9bccced..8719e1fe9d 100644
--- a/tests/Unit/Service/GroupsIntegrationTest.php
+++ b/tests/Unit/Service/GroupsIntegrationTest.php
@@ -62,6 +62,7 @@ public function testGetMatchingGroups(): void {
'label' => 'first test group (Namespace1)',
'email' => 'namespace1:testgroup',
'photo' => null,
+ 'source' => 'groups',
]
],
$actual