@plusscommunities/pluss-core-aws 1.5.20-beta.0 → 1.5.22-beta.0
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.
|
@@ -7,7 +7,9 @@ module.exports = async (accessKey, secretKey) => {
|
|
|
7
7
|
enabled: false,
|
|
8
8
|
sender: null,
|
|
9
9
|
};
|
|
10
|
+
console.log("getEmailServiceInfo");
|
|
10
11
|
const { emailConfig } = getConfig();
|
|
12
|
+
console.log("emailConfig", emailConfig);
|
|
11
13
|
const service = await getEmailService(accessKey, secretKey);
|
|
12
14
|
console.log("Amazon SES status", {
|
|
13
15
|
service,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const getRef = require("../common/getRef");
|
|
2
|
+
|
|
3
|
+
module.exports = async (site, key) => {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
getRef("sites", "Id", site)
|
|
6
|
+
.then((item) => {
|
|
7
|
+
if (item && item.Settings) {
|
|
8
|
+
return resolve(item.Settings[key]);
|
|
9
|
+
}
|
|
10
|
+
return resolve(undefined);
|
|
11
|
+
})
|
|
12
|
+
.catch((error) => {
|
|
13
|
+
return resolve(undefined);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const _ = require("lodash");
|
|
2
2
|
const indexQuery = require("../../db/common/indexQuery");
|
|
3
|
+
const getRef = require("../../db/common/getRef");
|
|
3
4
|
const scanRefRecursive = require("../../db/common/scanRefRecursive");
|
|
4
5
|
const userToUserPreview = require("../userToUserPreview");
|
|
6
|
+
const { getRowId, log } = require("..");
|
|
5
7
|
|
|
6
8
|
const getUsers = async (site) => {
|
|
7
9
|
if (site === "all") {
|
|
@@ -105,6 +107,47 @@ const getTagMatches = async (users, audienceTypeSelection, site) => {
|
|
|
105
107
|
);
|
|
106
108
|
};
|
|
107
109
|
|
|
110
|
+
const getEventMatches = async (users, audienceTypeSelection) => {
|
|
111
|
+
const logId = log("getEventMatches", "input", {
|
|
112
|
+
usersLength: users.length,
|
|
113
|
+
audienceTypeSelection,
|
|
114
|
+
});
|
|
115
|
+
let eventAudiences = [];
|
|
116
|
+
if (Array.isArray(audienceTypeSelection)) {
|
|
117
|
+
eventAudiences = _.filter(
|
|
118
|
+
audienceTypeSelection,
|
|
119
|
+
(at) => at.AudienceType === "EventAudience"
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
eventAudiences.push({ AudienceTypeSelection: audienceTypeSelection });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let userIds = [];
|
|
126
|
+
|
|
127
|
+
for (let i = 0; i < eventAudiences.length; i++) {
|
|
128
|
+
log("getEventMatches", "MatchingEventAudience", eventAudiences[i], logId);
|
|
129
|
+
const eventRep = await getRef(
|
|
130
|
+
"eventreps",
|
|
131
|
+
"RowId",
|
|
132
|
+
getRowId(
|
|
133
|
+
eventAudiences[i].AudienceTypeSelection.RowId,
|
|
134
|
+
eventAudiences[i].AudienceTypeSelection.RepId
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
if (eventRep && eventRep.Attendees) {
|
|
138
|
+
userIds = _.concat(userIds, Object.keys(eventRep.Attendees));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
log("getEventMatches", "userIdsLength", userIds.length, logId);
|
|
142
|
+
}
|
|
143
|
+
return _.filter(users, (u) => {
|
|
144
|
+
log("getEventMatches", "userId", u.id, logId);
|
|
145
|
+
log("getEventMatches", "containsUserId", _.includes(userIds, u.id), logId);
|
|
146
|
+
|
|
147
|
+
return _.includes(userIds, u.id);
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
108
151
|
module.exports = async (
|
|
109
152
|
site,
|
|
110
153
|
audienceType,
|
|
@@ -138,11 +181,20 @@ module.exports = async (
|
|
|
138
181
|
audienceTypeSelection,
|
|
139
182
|
site
|
|
140
183
|
);
|
|
184
|
+
const eventMatches = await getEventMatches(users, audienceTypeSelection);
|
|
141
185
|
|
|
142
186
|
// console.log("categoryMatches", categoryMatches);
|
|
143
187
|
// console.log("typeMatches", typeMatches);
|
|
144
188
|
// console.log("tagMatches", tagMatches);
|
|
145
|
-
return _.unionBy(
|
|
189
|
+
return _.unionBy(
|
|
190
|
+
categoryMatches,
|
|
191
|
+
typeMatches,
|
|
192
|
+
tagMatches,
|
|
193
|
+
eventMatches,
|
|
194
|
+
"id"
|
|
195
|
+
);
|
|
196
|
+
case "EventAudience":
|
|
197
|
+
return await getEventMatches(users, audienceTypeSelection);
|
|
146
198
|
case "Category":
|
|
147
199
|
return await getCategoryMatches(users, audienceTypeSelection, site);
|
|
148
200
|
case "UserType":
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const getSiteSetting = require("../../db/auth/getSiteSetting");
|
|
2
|
+
|
|
3
|
+
module.exports = async (site, key, expectedValue) => {
|
|
4
|
+
return new Promise(async (resolve) => {
|
|
5
|
+
if (!site) {
|
|
6
|
+
return resolve(false);
|
|
7
|
+
}
|
|
8
|
+
const siteSetting = await getSiteSetting(site, key);
|
|
9
|
+
return resolve(siteSetting === expectedValue);
|
|
10
|
+
});
|
|
11
|
+
};
|
package/helper/sendEmail.js
CHANGED
|
@@ -36,7 +36,9 @@ module.exports = async (
|
|
|
36
36
|
bcc = null,
|
|
37
37
|
} = {}
|
|
38
38
|
) => {
|
|
39
|
+
console.log("sendEmail", { toEmail, subject, content, useTemplate });
|
|
39
40
|
const { communityConfig, serverlessConfig, emailConfig } = getConfig();
|
|
41
|
+
console.log("emailConfig", emailConfig);
|
|
40
42
|
|
|
41
43
|
if (useTemplate) {
|
|
42
44
|
content = `<div style="padding: 24px; padding-top: 0px; background-color: #f2f4f8;margin: 0px;">
|
|
@@ -77,10 +79,12 @@ module.exports = async (
|
|
|
77
79
|
html: content,
|
|
78
80
|
};
|
|
79
81
|
|
|
82
|
+
console.log("getting email service", serverlessConfig);
|
|
80
83
|
const sesInfo = await getEmailServiceInfo(
|
|
81
84
|
serverlessConfig.key,
|
|
82
85
|
serverlessConfig.secret
|
|
83
86
|
);
|
|
87
|
+
console.log("sesInfo", sesInfo);
|
|
84
88
|
|
|
85
89
|
if (sesInfo.enabled) {
|
|
86
90
|
try {
|
package/package.json
CHANGED