aboutsummaryrefslogtreecommitdiffstats
path: root/apps/contactsinteraction
diff options
context:
space:
mode:
authorhamza221 <hamzamahjoubi221@gmail.com>2023-10-22 16:37:44 +0200
committerhamza221 <hamzamahjoubi221@gmail.com>2023-10-24 13:03:59 +0200
commit6ab76917c91ec8279a2caa9b99143077ab3fe1a6 (patch)
treea08cbf2dd9cdc8c35817fe991f41282aa140be54 /apps/contactsinteraction
parentf88c34b604e5e82950d65e4531403ff5930a2637 (diff)
downloadnextcloud-server-6ab76917c91ec8279a2caa9b99143077ab3fe1a6.tar.gz
nextcloud-server-6ab76917c91ec8279a2caa9b99143077ab3fe1a6.zip
Fix: duplicating contacts with the Recently contacted feature
Signed-off-by: hamza221 <hamzamahjoubi221@gmail.com>
Diffstat (limited to 'apps/contactsinteraction')
-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 000954a9016..499a9f28ca5 100644
--- a/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
+++ b/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
@@ -76,15 +76,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);
}
@@ -104,29 +114,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);
}