@plusscommunities/pluss-core-aws 2.0.7-beta.3 → 2.0.7-beta.5

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.
@@ -155,6 +155,8 @@ const getEventMatches = async (users, audienceTypeSelection) => {
155
155
  * @param {string} audienceType - The type of audience to retrieve.
156
156
  * @param {string | Array} audienceTypeSelection - The selection criteria for the audience.
157
157
  * @param {boolean} [preview=true] - Indicates whether to retrieve a preview of the users in the audience.
158
+ * @param {boolean} [includeType=true] - Indicates whether to include the user type in the preview.
159
+ * @param {boolean} [includeSite=true] - Indicates whether to include the site in the preview.
158
160
  * @returns {Array} - The audience that matches the specified criteria.
159
161
  */
160
162
  module.exports = async (
@@ -171,44 +173,57 @@ module.exports = async (
171
173
  _.filter(userData, (u) => !u.Deleted),
172
174
  (u) => {
173
175
  return preview
174
- ? userToUserPreview(u, includeType, includeSite)
176
+ ? userToUserPreview(u, true, true)
175
177
  : { id: u.Id || u.userId, ...u };
176
178
  }
177
179
  );
178
- if (!audienceType) return users;
179
-
180
- switch (audienceType) {
181
- case "All":
182
- return users;
183
- case "Custom":
184
- const categoryMatches = await getCategoryMatches(
185
- users,
186
- audienceTypeSelection,
187
- site
188
- );
189
- const typeMatches = getTypeMatches(users, audienceTypeSelection);
190
- const tagMatches = await getTagMatches(
191
- users,
192
- audienceTypeSelection,
193
- site
194
- );
195
- const eventMatches = await getEventMatches(users, audienceTypeSelection);
196
-
197
- // console.log("categoryMatches", categoryMatches);
198
- // console.log("typeMatches", typeMatches);
199
- // console.log("tagMatches", tagMatches);
200
- return _.unionBy(
201
- categoryMatches,
202
- typeMatches,
203
- tagMatches,
204
- eventMatches,
205
- "id"
206
- );
207
- case "EventAudience":
208
- return await getEventMatches(users, audienceTypeSelection);
209
- case "Category":
210
- return await getCategoryMatches(users, audienceTypeSelection, site);
211
- case "UserType":
212
- return getTypeMatches(users, audienceTypeSelection);
180
+ result = users;
181
+ if (audienceType) {
182
+ switch (audienceType) {
183
+ case "All":
184
+ break;
185
+ case "Custom":
186
+ const categoryMatches = await getCategoryMatches(
187
+ users,
188
+ audienceTypeSelection,
189
+ site
190
+ );
191
+ const typeMatches = getTypeMatches(users, audienceTypeSelection);
192
+ const tagMatches = await getTagMatches(
193
+ users,
194
+ audienceTypeSelection,
195
+ site
196
+ );
197
+ const eventMatches = await getEventMatches(
198
+ users,
199
+ audienceTypeSelection
200
+ );
201
+
202
+ // console.log("categoryMatches", categoryMatches);
203
+ // console.log("typeMatches", typeMatches);
204
+ // console.log("tagMatches", tagMatches);
205
+ result = _.unionBy(
206
+ categoryMatches,
207
+ typeMatches,
208
+ tagMatches,
209
+ eventMatches,
210
+ "id"
211
+ );
212
+ break;
213
+ case "EventAudience":
214
+ result = await getEventMatches(users, audienceTypeSelection);
215
+ break;
216
+ case "Category":
217
+ result = await getCategoryMatches(users, audienceTypeSelection, site);
218
+ break;
219
+ case "UserType":
220
+ result = getTypeMatches(users, audienceTypeSelection);
221
+ break;
222
+ default:
223
+ break;
224
+ }
213
225
  }
226
+ return result.map((user) => {
227
+ return userToUserPreview(user, includeType, includeSite);
228
+ });
214
229
  };
@@ -20,7 +20,14 @@ module.exports = async (site, permissions) => {
20
20
  };
21
21
  });
22
22
  log("getUsersByPermission", "audienceMatches", audienceMatches, logId);
23
- const audience = await getAudience(site, "Custom", audienceMatches);
23
+ const audience = await getAudience(
24
+ site,
25
+ "Custom",
26
+ audienceMatches,
27
+ true,
28
+ false,
29
+ false
30
+ );
24
31
  log("getUsersByPermission", "audienceLength", audience.length, logId);
25
32
 
26
33
  return audience;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "2.0.7-beta.3",
3
+ "version": "2.0.7-beta.5",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",