summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhamza221 <hamzamahjoubi221@gmail.com>2023-10-22 16:37:44 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-10-24 19:03:36 +0000
commitfa72f8ee52794150495bcf1b6d9704dca7c0e549 (patch)
tree9f3edb9d46833508303e2a533dbb3cf3c489846e
parenteb83fcb63b9ed0da6efe8f9193f3ef4a908cbf52 (diff)
downloadnextcloud-server-fa72f8ee52794150495bcf1b6d9704dca7c0e549.tar.gz
nextcloud-server-fa72f8ee52794150495bcf1b6d9704dca7c0e549.zip
Fix: duplicating contacts with the Recently contacted feature
Signed-off-by: hamza221 <hamzamahjoubi221@gmail.com>
-rw-r--r--apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php39
1 files changed, 14 insertions, 25 deletions
diff --git a/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php b/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
index 2064136c392..b8892cc6219 100644
--- a/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
+++ b/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
@@ -89,15 +89,25 @@ class ContactInteractionListener implements IEventListener {
$uid = $event->getUid();
$email = $event->getEmail();
$federatedCloudId = $event->getFederatedCloudId();
- $existing = $this->mapper->findMatch(
+
+ $existingContact = $this->cardSearchDao->findExisting(
+ $event->getActor(),
+ $uid,
+ $email,
+ $federatedCloudId);
+ if ($existingContact !== null) {
+ return;
+ }
+
+ $existingRecentlyContacted = $this->mapper->findMatch(
$event->getActor(),
$uid,
$email,
$federatedCloudId
);
- if (!empty($existing)) {
+ if (!empty($existingRecentlyContacted)) {
$now = $this->timeFactory->getTime();
- foreach ($existing as $c) {
+ foreach ($existingRecentlyContacted as $c) {
$c->setLastContact($now);
$this->mapper->update($c);
}
@@ -117,29 +127,8 @@ class ContactInteractionListener implements IEventListener {
$contact->setFederatedCloudId($federatedCloudId);
}
$contact->setLastContact($this->timeFactory->getTime());
+ $contact->setCard($this->generateCard($contact));
- $copy = $this->cardSearchDao->findExisting(
- $event->getActor(),
- $uid,
- $email,
- $federatedCloudId
- );
- if ($copy !== null) {
- try {
- $parsed = Reader::read($copy, Reader::OPTION_FORGIVING);
- $parsed->CATEGORIES = $this->l10n->t('Recently contacted');
- $contact->setCard($parsed->serialize());
- } catch (Throwable $e) {
- $this->logger->warning(
- 'Could not parse card to add recent category: ' . $e->getMessage(),
- [
- 'exception' => $e,
- ]);
- $contact->setCard($copy);
- }
- } else {
- $contact->setCard($this->generateCard($contact));
- }
$this->mapper->insert($contact);
}, $this->dbConnection);
}