Skip to content

Commit

Permalink
Merge pull request #102 from CodethinkLabs/bobclough/fix-duplicate-me…
Browse files Browse the repository at this point in the history
…ssages

Only log duplicate email & group message when we're not in refresh mode
  • Loading branch information
thinkl33t authored Dec 6, 2023
2 parents e0e655b + 6df3ad3 commit 7d8d5ac
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions lifecycle/target_suitecrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@ def _fetch_all_emails(self, refresh=False):
address = ent["attributes"]["email_address"]
_id = ent["id"]
if address in self._emails_to_id:
logging.warning(
(
"Duplicate E-mail address entries found in suitecrm server:"
"Address '%s' has IDs '%s' and '%s'. Using the first one only."
),
address,
self._emails_to_id[address],
_id,
)
if not refresh:
logging.warning(
(
"Duplicate E-mail address entries found in suitecrm server:"
"Address '%s' has IDs '%s' and '%s'. Using the first one only."
),
address,
self._emails_to_id[address],
_id,
)
else:
self._emails_to_id[address] = _id
return self._emails_to_id
Expand All @@ -279,15 +280,16 @@ def _fetch_all_groups(self, refresh=False):
groupname = ent["attributes"]["name"]
_id = ent["id"]
if groupname in self._groups_to_id:
logging.warning(
(
"Duplicate Group entries found in suitecrm server:"
"Group '%s' has IDs '%s' and '%s'. Using the first one only."
),
groupname,
self._groups_to_id[groupname],
_id,
)
if not refresh:
logging.warning(
(
"Duplicate Group entries found in suitecrm server:"
"Group '%s' has IDs '%s' and '%s'. Using the first one only."
),
groupname,
self._groups_to_id[groupname],
_id,
)
else:
self._groups_to_id[groupname] = _id
self._groups_to_attributes[groupname] = ent["attributes"]
Expand Down

0 comments on commit 7d8d5ac

Please sign in to comment.