@plusscommunities/pluss-core-aws 1.5.3 → 1.5.6
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.
|
@@ -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 } = require("..");
|
|
5
7
|
|
|
6
8
|
const getUsers = async (site) => {
|
|
7
9
|
if (site === "all") {
|
|
@@ -105,6 +107,36 @@ const getTagMatches = async (users, audienceTypeSelection, site) => {
|
|
|
105
107
|
);
|
|
106
108
|
};
|
|
107
109
|
|
|
110
|
+
const getEventMatches = async (users, audienceTypeSelection) => {
|
|
111
|
+
let eventAudiences = [];
|
|
112
|
+
if (Array.isArray(audienceTypeSelection)) {
|
|
113
|
+
eventAudiences = _.filter(
|
|
114
|
+
audienceTypeSelection,
|
|
115
|
+
(at) => at.AudienceType === "EventAudience"
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
eventAudiences.push({ AudienceTypeSelection: audienceTypeSelection });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const userIds = [];
|
|
122
|
+
|
|
123
|
+
for (let i = 0; i < eventAudiences.length; i++) {
|
|
124
|
+
eventAudiences[0];
|
|
125
|
+
const eventRep = await getRef(
|
|
126
|
+
"eventreps",
|
|
127
|
+
"RowId",
|
|
128
|
+
getRowId(
|
|
129
|
+
eventAudiences[0].AudienceTypeSelection.RowId,
|
|
130
|
+
eventAudiences[0].AudienceTypeSelection.RepId
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
if (eventRep && eventRep.Attendees) {
|
|
134
|
+
userIds.push.apply(userIds, Object.keys(eventRep.Attendees));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return _.filter(users, (u) => _.some(userIds, u.id));
|
|
138
|
+
};
|
|
139
|
+
|
|
108
140
|
module.exports = async (
|
|
109
141
|
site,
|
|
110
142
|
audienceType,
|
|
@@ -138,11 +170,20 @@ module.exports = async (
|
|
|
138
170
|
audienceTypeSelection,
|
|
139
171
|
site
|
|
140
172
|
);
|
|
173
|
+
const eventMatches = await getEventMatches(users, audienceTypeSelection);
|
|
141
174
|
|
|
142
175
|
// console.log("categoryMatches", categoryMatches);
|
|
143
176
|
// console.log("typeMatches", typeMatches);
|
|
144
177
|
// console.log("tagMatches", tagMatches);
|
|
145
|
-
return _.unionBy(
|
|
178
|
+
return _.unionBy(
|
|
179
|
+
categoryMatches,
|
|
180
|
+
typeMatches,
|
|
181
|
+
tagMatches,
|
|
182
|
+
eventMatches,
|
|
183
|
+
"id"
|
|
184
|
+
);
|
|
185
|
+
case "EventAudience":
|
|
186
|
+
return await getEventMatches(users, audienceTypeSelection);
|
|
146
187
|
case "Category":
|
|
147
188
|
return await getCategoryMatches(users, audienceTypeSelection, site);
|
|
148
189
|
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
|
+
};
|
|
@@ -17,7 +17,10 @@ const getCircularReplacer = () => {
|
|
|
17
17
|
|
|
18
18
|
module.exports = (statusCode, body) => {
|
|
19
19
|
if ([400, 402, 422].includes(statusCode)) console.error(body);
|
|
20
|
-
const jsonBody = JSON.stringify(
|
|
20
|
+
const jsonBody = JSON.stringify(
|
|
21
|
+
(body && body.error) || body,
|
|
22
|
+
getCircularReplacer()
|
|
23
|
+
);
|
|
21
24
|
return {
|
|
22
25
|
statusCode,
|
|
23
26
|
headers: {
|