biz-email-builder-shared 1.6.79 → 1.6.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendFromSendGrid.d.ts","sourceRoot":"","sources":["../../src/utilities/sendFromSendGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMpC,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"sendFromSendGrid.d.ts","sourceRoot":"","sources":["../../src/utilities/sendFromSendGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMpC,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,gBA4CnJ"}
|
|
@@ -14,13 +14,7 @@ async function sendFromSendGrid(config, recipient, subject, text, isHtml, analyt
|
|
|
14
14
|
url: "/v3/mail/send",
|
|
15
15
|
body: {
|
|
16
16
|
personalizations: [
|
|
17
|
-
{
|
|
18
|
-
to: normalizeEmails(recipient.to),
|
|
19
|
-
cc: recipient.cc ? normalizeEmails(recipient.cc) : undefined,
|
|
20
|
-
bcc: recipient.bcc ? normalizeEmails(recipient.bcc) : undefined,
|
|
21
|
-
subject,
|
|
22
|
-
custom_args: Object.assign({}, ((analytics === null || analytics === void 0 ? void 0 : analytics.custom_args) && { custom_args: analytics.custom_args })),
|
|
23
|
-
},
|
|
17
|
+
Object.assign({ to: normalizeEmails(recipient.to), cc: recipient.cc ? normalizeEmails(recipient.cc) : undefined, bcc: recipient.bcc ? normalizeEmails(recipient.bcc) : undefined, subject }, ((analytics === null || analytics === void 0 ? void 0 : analytics.custom_args) && { custom_args: analytics.custom_args })),
|
|
24
18
|
],
|
|
25
19
|
from: {
|
|
26
20
|
email: config.email,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendMail.d.ts","sourceRoot":"","sources":["../../src/utilities/sendMail.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAOhD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,GAAG,EACd,cAAc,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sendMail.d.ts","sourceRoot":"","sources":["../../src/utilities/sendMail.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAOhD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,GAAG,EACd,cAAc,CAAC,EAAE,MAAM,gBA8DxB"}
|
|
@@ -5,33 +5,30 @@ const mongoose_1 = require("mongoose");
|
|
|
5
5
|
const entity_1 = require("../entity");
|
|
6
6
|
const sendMailViaEnvFallback_1 = require("./sendMailViaEnvFallback");
|
|
7
7
|
const sendMailViaSMTP_1 = require("./sendMailViaSMTP");
|
|
8
|
-
const errorHandler_1 = require("../resHandler/errorHandler");
|
|
9
8
|
const sendFromGmail_1 = require("./sendFromGmail");
|
|
10
9
|
const cryptoUtils_1 = require("./cryptoUtils");
|
|
11
|
-
const serverMessages_1 = require("./serverMessages");
|
|
12
10
|
const sendFromSendGrid_1 = require("./sendFromSendGrid");
|
|
13
11
|
async function sendMail(userId, recipient, subject, body, attachments, isHtml, analytics, organisationId) {
|
|
14
12
|
let config = null;
|
|
15
|
-
let isOwner;
|
|
16
|
-
let isMember;
|
|
13
|
+
let isOwner = null;
|
|
14
|
+
let isMember = null;
|
|
17
15
|
// If organisationId is provided
|
|
18
16
|
if (organisationId) {
|
|
19
17
|
isOwner = await entity_1.OrganisationModel.findOne({ createdBy: new mongoose_1.Types.ObjectId(userId), isDeleted: false }).lean();
|
|
20
18
|
if (isOwner) {
|
|
21
19
|
config = await entity_1.EmailConfigurationModel.findOne({ user: new mongoose_1.Types.ObjectId(userId), isDeleted: false }).lean();
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
throw new errorHandler_1.ForbiddenRequestError(serverMessages_1.SERVER_MESSAGES.SE_USER_IS_NOT_PART_OF_ORGANISATION);
|
|
21
|
+
else {
|
|
22
|
+
isMember = await entity_1.OrganisationTeamModel.findOne({
|
|
23
|
+
organisationId: new mongoose_1.Types.ObjectId(organisationId),
|
|
24
|
+
user: new mongoose_1.Types.ObjectId(userId),
|
|
25
|
+
isDeleted: false,
|
|
26
|
+
inviteStatus: "ACCEPTED",
|
|
27
|
+
}).lean();
|
|
28
|
+
if (isMember) {
|
|
29
|
+
const org = await entity_1.OrganisationModel.findById(organisationId);
|
|
30
|
+
config = await entity_1.EmailConfigurationModel.findOne({ user: org === null || org === void 0 ? void 0 : org.createdBy, isDeleted: false }).lean();
|
|
31
|
+
}
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
else {
|