From d9e61704cd04587259b868bdc8cb2fe9c65b36ba Mon Sep 17 00:00:00 2001 From: Sebastian Pongratz <s.pongratz@adito.de> Date: Tue, 31 Aug 2021 07:34:35 +0000 Subject: [PATCH] Cm 1085591 modular communication fix --- .../recordcontainers/db/onDBDelete.js | 3 ++- process/Contact_lib/process.js | 2 +- process/EmailFilterHandling_lib/process.js | 3 ++- process/register_rest/process.js | 9 +++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/entity/Organisation_entity/recordcontainers/db/onDBDelete.js b/entity/Organisation_entity/recordcontainers/db/onDBDelete.js index df7ebcfc65..cb4a6f482b 100644 --- a/entity/Organisation_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Organisation_entity/recordcontainers/db/onDBDelete.js @@ -12,7 +12,8 @@ DuplicateScannerUtils.deleteHasDuplicateEntries(EntityUtils.getCurrentEntitytId( new AttributeRelationQuery(contactId, null, ContextUtils.getCurrentContextId()) .deleteAllAttributes(); -newWhere("COMMUNICATION.CONTACT_ID", contactId).deleteData(); +newWhere("COMMUNICATION.OBJECT_ROWID", contactId) +.and("COMMUNICATION.OBJECT_TYPE", "Contact").deleteData(); newWhere("ADDRESS.CONTACT_ID", contactId).deleteData(); newWhere("COMMUNICATIONSETTINGS.CONTACT_ID", contactId).deleteData(); newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", contactId).deleteData(); diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index 20362d71db..a570ceaa59 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -762,7 +762,7 @@ ContactUtils.getContactIdByEmail = function(pEmail) var email = EmailUtils.extractAddress(pEmail).toUpperCase(); var contactId = newSelect("CONTACT.CONTACTID") .from("COMMUNICATION") - .join("CONTACT", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID") + .join("CONTACT", newWhere("COMMUNICATION.OBEJCT_ROWID = CONTACT.CONTACTID").and("COMMUNICATION.OBJECT_TYPE", "Contact")) .where("COMMUNICATION.ADDR", email, "upper(#) = ?") .cell(); return contactId; diff --git a/process/EmailFilterHandling_lib/process.js b/process/EmailFilterHandling_lib/process.js index 156337cb24..afbc40f1ac 100644 --- a/process/EmailFilterHandling_lib/process.js +++ b/process/EmailFilterHandling_lib/process.js @@ -124,9 +124,10 @@ IncomingEmailFilterProcessor.prototype.checkBodyForIds = function (pEmail) //if no maillog was found at least match the mailaddress to a contact if(!mailLogId && mailAddress) { - contactId = newSelect("COMMUNICATION.CONTACT_ID") + contactId = newSelect("COMMUNICATION.OBJECT_ROWID") .from("COMMUNICATION") .where("COMMUNICATION.ADDR",mailAddress) + .and("COMMUNICATION.OBJECT_TYPE", "Contact") .cell() } diff --git a/process/register_rest/process.js b/process/register_rest/process.js index 9c9ae2bebd..ecc5f3f8f0 100644 --- a/process/register_rest/process.js +++ b/process/register_rest/process.js @@ -48,7 +48,7 @@ function _findPerson(pFirstname, pLastname, pMailAddress) var contactId = newSelect("CONTACT.CONTACTID") .from("CONTACT") .join("PERSON","CONTACT.PERSON_ID = PERSON.PERSONID") - .join("COMMUNICATION","COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID") + .join("COMMUNICATION",newWhere("COMMUNICATION.OBJECT_ROWID = CONTACT.CONTACTID").and("COMMUNICATION.OBJECT_TYPE", "Contact")) .whereIfSet("PERSON.FIRSTNAME",pFirstname) .andIfSet("PERSON.LASTNAME",pLastname) .and("COMMUNICATION.MEDIUM_ID",$KeywordRegistry.communicationMedium$mail()) @@ -58,7 +58,7 @@ function _findPerson(pFirstname, pLastname, pMailAddress) if (!contactId){ contactId = newSelect("CONTACT.CONTACTID") .from("CONTACT") - .join("COMMUNICATION","COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID") + .join("COMMUNICATION",newWhere("COMMUNICATION.OBJECT_ROWID = CONTACT.CONTACTID").and("COMMUNICATION.OBJECT_TYPE", "Contact")) .where("COMMUNICATION.MEDIUM_ID",$KeywordRegistry.communicationMedium$mail()) .and("COMMUNICATION.ADDR",pMailAddress) .and("CONTACT.PERSON_ID is not null") @@ -109,12 +109,13 @@ function _insertPerson(pFirstname, pLastname, pMailAddress, pSalutation) .tableName("COMMUNICATION") .insertFields({ "COMMUNICATIONID": util.getNewUUID(), - "CONTACT_ID" : contactId, + "OBJECT_ROWID" : contactId, "MEDIUM_ID": $KeywordRegistry.communicationMedium$mail(), "ADDR": pMailAddress, "ISSTANDARD" : "1", "USER_NEW": "register_rest", - "DATE_NEW": vars.get("$sys.date") + "DATE_NEW": vars.get("$sys.date"), + "OBJECT_TYPE" : "Contact" }); return contactId; -- GitLab