@plusscommunities/pluss-core-aws 2.0.25-auth.0 → 2.0.25-beta.1

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.
Files changed (90) hide show
  1. package/aws/getDefaultEmailAddress.js +21 -21
  2. package/aws/getEmailService.js +16 -16
  3. package/aws/getEmailServiceInfo.js +26 -26
  4. package/aws/sendEmail.js +31 -31
  5. package/config.js +1 -1
  6. package/db/activity/publishActivity.js +22 -22
  7. package/db/analytics/checkActivityExists.js +15 -15
  8. package/db/analytics/logAnalyticsActivity.js +69 -37
  9. package/db/analytics/scheduleOldAggregation.js +14 -14
  10. package/db/auth/getSiteSetting.js +12 -12
  11. package/db/auth/getSiteUserTypes.js +16 -16
  12. package/db/auth/getUserAuth.js +13 -13
  13. package/db/automatedactions/getActionBySiteTrigger.js +9 -9
  14. package/db/common/deleteRef.js +21 -21
  15. package/db/common/editRef.js +36 -36
  16. package/db/common/getRef.js +23 -23
  17. package/db/common/getTableCount.js +18 -18
  18. package/db/common/indexQuery.js +17 -17
  19. package/db/common/indexQueryRecursive.js +20 -20
  20. package/db/common/scanRef.js +18 -18
  21. package/db/common/scanRefRecursive.js +20 -20
  22. package/db/common/updateAttribute.js +27 -27
  23. package/db/common/updateRef.js +20 -20
  24. package/db/linkedUsers/getLinkedBy.js +21 -21
  25. package/db/linkedUsers/getLinkedTo.js +21 -21
  26. package/db/notifications/deleteNotificationsByEntity.js +21 -21
  27. package/db/notifications/getNotificationSetting.js +14 -14
  28. package/db/notifications/publishNotifications.js +39 -39
  29. package/db/scheduledActions/deleteActionQueue.js +1 -1
  30. package/db/scheduledActions/getActionQueueByEntityId.js +10 -10
  31. package/db/scheduledActions/getActionQueueByEntityKey.js +9 -9
  32. package/db/scheduledActions/getActionQueueById.js +9 -9
  33. package/db/scheduledActions/getActionQueueByTriggerAt.js +14 -14
  34. package/db/scheduledActions/updateActionQueue.js +29 -29
  35. package/db/strings/getString.js +20 -20
  36. package/db/strings/logUpdate.js +18 -18
  37. package/db/templates/getTemplateById.js +1 -1
  38. package/db/templates/getTemplatesList.js +10 -10
  39. package/db/templates/updateTemplate.js +9 -9
  40. package/db/users/getRole.js +1 -1
  41. package/db/users/getUser.js +9 -9
  42. package/db/users/getUserByEmail.js +17 -17
  43. package/helper/audience/filterByAudienceType.js +27 -27
  44. package/helper/audience/filterOnAudienceType.js +26 -26
  45. package/helper/audience/getAudience.js +187 -187
  46. package/helper/audience/getMatchingAudienceTypes.js +21 -21
  47. package/helper/audience/getMatchingAudienceTypesFromPreview.js +60 -60
  48. package/helper/audience/getMatchingTags.js +15 -15
  49. package/helper/audience/isValidAudience.js +20 -20
  50. package/helper/auth/checkTokenBlacklist.js +17 -17
  51. package/helper/auth/getApiKeyFromReq.js +2 -2
  52. package/helper/auth/getSessionUser.js +70 -85
  53. package/helper/auth/getSessionUserFromReq.js +2 -2
  54. package/helper/auth/getSessionUserFromReqAuthKey.js +11 -11
  55. package/helper/auth/validateApiKey.js +32 -32
  56. package/helper/auth/validateMasterAuth.js +174 -174
  57. package/helper/auth/validateSiteAccess.js +12 -12
  58. package/helper/auth/validateSiteSetting.js +7 -7
  59. package/helper/auth/validateUserLoggedIn.js +19 -19
  60. package/helper/createGuid.js +5 -5
  61. package/helper/generateJsonResponse.js +27 -27
  62. package/helper/getUserPreview.js +57 -57
  63. package/helper/getUserPreviewFromHeader.js +17 -17
  64. package/helper/getUserPreviewFromReq.js +17 -17
  65. package/helper/hqPublishing.js +337 -0
  66. package/helper/index.js +28 -28
  67. package/helper/notifySiteConfigs.js +132 -0
  68. package/helper/opengraph/getOpenGraph.js +12 -12
  69. package/helper/rates/checkRateLimit.js +38 -38
  70. package/helper/requestToSource.js +10 -10
  71. package/helper/sendEmail.js +120 -120
  72. package/helper/templates/replacePlaceHolders.js +29 -29
  73. package/helper/time/getLocalTimestamp.js +18 -18
  74. package/helper/time/getSiteTimezone.js +11 -11
  75. package/helper/triggerAutomatedAction.js +25 -25
  76. package/helper/userToUserPreview.js +23 -23
  77. package/helper/users/getUserTypesByPermission.js +24 -24
  78. package/helper/users/getUsersByPermission.js +20 -20
  79. package/notification/prepNotification.js +144 -144
  80. package/notification/sendNotifications.js +166 -166
  81. package/package.json +35 -40
  82. package/templates/supportTicketEmails.js +8 -8
  83. package/helper/auth/context/AuthenticationContext.js +0 -50
  84. package/helper/auth/context/AuthenticationStrategy.js +0 -20
  85. package/helper/auth/context/auth0/Strategy.js +0 -12
  86. package/helper/auth/context/auth0/functions/decodeAccessToken.js +0 -102
  87. package/helper/auth/context/auth0/functions/getSessionUser.js +0 -21
  88. package/helper/auth/context/boltonclarke/Strategy.js +0 -10
  89. package/helper/auth/context/cognito/Strategy.js +0 -12
  90. package/helper/auth/context/cognito/functions/getSessionUser.js +0 -76
@@ -5,50 +5,50 @@ const sendNotifications = require("../../notification/sendNotifications");
5
5
  const prepNotification = require("../../notification/prepNotification");
6
6
 
7
7
  const saveNotification = (receiver, notification) => {
8
- const toSave = { ...notification };
8
+ const toSave = { ...notification };
9
9
 
10
- toSave.UserId = receiver;
11
- toSave.RowId = getMultiRowId([toSave.Site, toSave.Type, toSave.Id, receiver]);
12
- toSave.Seen = false;
13
- toSave.Clicked = false;
10
+ toSave.UserId = receiver;
11
+ toSave.RowId = getMultiRowId([toSave.Site, toSave.Type, toSave.Id, receiver]);
12
+ toSave.Seen = false;
13
+ toSave.Clicked = false;
14
14
 
15
- updateRef(`notifications`, toSave)
16
- .then(() => {
17
- //resolve();
18
- })
19
- .catch((error) => {
20
- //reject(error);
21
- });
15
+ updateRef(`notifications`, toSave)
16
+ .then(() => {
17
+ //resolve();
18
+ })
19
+ .catch((error) => {
20
+ //reject(error);
21
+ });
22
22
  };
23
23
 
24
24
  module.exports = async (
25
- receivers,
26
- type,
27
- site,
28
- id,
29
- data,
30
- sendPush,
31
- config = { type: "app", id: null, ignoreMute: false, raiseError: false }
25
+ receivers,
26
+ type,
27
+ site,
28
+ id,
29
+ data,
30
+ sendPush,
31
+ config = { type: "app", id: null, ignoreMute: false, raiseError: false },
32
32
  ) => {
33
- const notification = {};
34
- notification.Timestamp = moment.utc().valueOf();
35
- notification.Type = type;
36
- notification.Site = site;
37
- notification.Id = id;
38
- notification.Data = data;
33
+ const notification = {};
34
+ notification.Timestamp = moment.utc().valueOf();
35
+ notification.Type = type;
36
+ notification.Site = site;
37
+ notification.Id = id;
38
+ notification.Data = data;
39
39
 
40
- receivers.forEach((receiver) => {
41
- saveNotification(receiver, notification);
42
- });
43
- if (sendPush) {
44
- const notiData = prepNotification(notification);
45
- await sendNotifications(
46
- receivers,
47
- notiData.Text,
48
- type,
49
- id,
50
- notiData,
51
- config
52
- );
53
- }
40
+ receivers.forEach((receiver) => {
41
+ saveNotification(receiver, notification);
42
+ });
43
+ if (sendPush) {
44
+ const notiData = prepNotification(notification);
45
+ await sendNotifications(
46
+ receivers,
47
+ notiData.Text,
48
+ type,
49
+ id,
50
+ notiData,
51
+ config,
52
+ );
53
+ }
54
54
  };
@@ -1,5 +1,5 @@
1
1
  const deleteRef = require("../common/deleteRef");
2
2
 
3
3
  module.exports = (id) => {
4
- return deleteRef("actionqueue", "RowId", id);
4
+ return deleteRef("actionqueue", "RowId", id);
5
5
  };
@@ -1,15 +1,15 @@
1
1
  const indexQuery = require("../common/indexQuery");
2
2
 
3
3
  module.exports = async (entityKey, entityId) => {
4
- const query = {
5
- IndexName: "EntityKeyEntityIdIndex",
6
- KeyConditionExpression: "EntityKey = :entityKey and EntityId = :entityId",
7
- ExpressionAttributeValues: {
8
- ":entityKey": entityKey,
9
- ":entityId": entityId,
10
- },
11
- };
4
+ const query = {
5
+ IndexName: "EntityKeyEntityIdIndex",
6
+ KeyConditionExpression: "EntityKey = :entityKey and EntityId = :entityId",
7
+ ExpressionAttributeValues: {
8
+ ":entityKey": entityKey,
9
+ ":entityId": entityId,
10
+ },
11
+ };
12
12
 
13
- const { Items } = await indexQuery("actionqueue", query);
14
- return Items;
13
+ const { Items } = await indexQuery("actionqueue", query);
14
+ return Items;
15
15
  };
@@ -1,14 +1,14 @@
1
1
  const indexQueryRecursive = require("../common/indexQueryRecursive");
2
2
 
3
3
  module.exports = async (site, entityKey) => {
4
- const query = {
5
- IndexName: "SiteEntityKeyIndex",
6
- KeyConditionExpression: "Site = :site and EntityKey = :entityKey",
7
- ExpressionAttributeValues: {
8
- ":site": site,
9
- ":entityKey": entityKey,
10
- },
11
- };
4
+ const query = {
5
+ IndexName: "SiteEntityKeyIndex",
6
+ KeyConditionExpression: "Site = :site and EntityKey = :entityKey",
7
+ ExpressionAttributeValues: {
8
+ ":site": site,
9
+ ":entityKey": entityKey,
10
+ },
11
+ };
12
12
 
13
- return await indexQueryRecursive("actionqueue", query);
13
+ return await indexQueryRecursive("actionqueue", query);
14
14
  };
@@ -1,13 +1,13 @@
1
1
  const getRef = require("../common/getRef");
2
2
 
3
3
  module.exports = (rowId) => {
4
- return new Promise((resolve, reject) => {
5
- getRef("actionqueue", "RowId", rowId)
6
- .then((ev) => {
7
- resolve(ev);
8
- })
9
- .catch((error) => {
10
- reject(error);
11
- });
12
- });
4
+ return new Promise((resolve, reject) => {
5
+ getRef("actionqueue", "RowId", rowId)
6
+ .then((ev) => {
7
+ resolve(ev);
8
+ })
9
+ .catch((error) => {
10
+ reject(error);
11
+ });
12
+ });
13
13
  };
@@ -1,20 +1,20 @@
1
1
  const indexQueryRecursive = require("../common/indexQueryRecursive");
2
2
 
3
3
  module.exports = async (
4
- site,
5
- minTime = 0,
6
- maxTime = Number.MAX_SAFE_INTEGER
4
+ site,
5
+ minTime = 0,
6
+ maxTime = Number.MAX_SAFE_INTEGER,
7
7
  ) => {
8
- const query = {
9
- IndexName: "SiteTriggerAtIndex",
10
- KeyConditionExpression:
11
- "Site = :site AND TriggerAt BETWEEN :minTime and :maxTime",
12
- ExpressionAttributeValues: {
13
- ":site": site,
14
- ":minTime": minTime,
15
- ":maxTime": maxTime,
16
- },
17
- };
8
+ const query = {
9
+ IndexName: "SiteTriggerAtIndex",
10
+ KeyConditionExpression:
11
+ "Site = :site AND TriggerAt BETWEEN :minTime and :maxTime",
12
+ ExpressionAttributeValues: {
13
+ ":site": site,
14
+ ":minTime": minTime,
15
+ ":maxTime": maxTime,
16
+ },
17
+ };
18
18
 
19
- return await indexQueryRecursive("actionqueue", query);
19
+ return await indexQueryRecursive("actionqueue", query);
20
20
  };
@@ -3,35 +3,35 @@ const moment = require("moment");
3
3
  const editRef = require("../common/editRef");
4
4
 
5
5
  module.exports = (rowId, update) => {
6
- return new Promise(async (resolve, reject) => {
7
- try {
8
- const now = moment().valueOf();
9
- const { Created, Updated, TriggerAt, Status, Recipients } = update;
10
- if (!rowId) {
11
- rowId = uuid.v1();
12
- if (!Created) update.Created = now;
13
- if (!Status) update.Status = "READY";
14
- } else {
15
- if (!Updated) update.Updated = now;
16
- }
17
- if (TriggerAt) {
18
- update.TriggerAt =
19
- typeof TriggerAt === "string"
20
- ? moment(TriggerAt).valueOf()
21
- : TriggerAt;
22
- }
23
- if (Recipients) {
24
- update.Recipients =
25
- typeof Recipients === "string" || Recipients instanceof String
26
- ? Recipients.split(",").map((r) => r.trim())
27
- : Recipients;
28
- }
6
+ return new Promise(async (resolve, reject) => {
7
+ try {
8
+ const now = moment().valueOf();
9
+ const { Created, Updated, TriggerAt, Status, Recipients } = update;
10
+ if (!rowId) {
11
+ rowId = uuid.v1();
12
+ if (!Created) update.Created = now;
13
+ if (!Status) update.Status = "READY";
14
+ } else {
15
+ if (!Updated) update.Updated = now;
16
+ }
17
+ if (TriggerAt) {
18
+ update.TriggerAt =
19
+ typeof TriggerAt === "string"
20
+ ? moment(TriggerAt).valueOf()
21
+ : TriggerAt;
22
+ }
23
+ if (Recipients) {
24
+ update.Recipients =
25
+ typeof Recipients === "string" || Recipients instanceof String
26
+ ? Recipients.split(",").map((r) => r.trim())
27
+ : Recipients;
28
+ }
29
29
 
30
- const updated = await editRef("actionqueue", "RowId", rowId, update);
30
+ const updated = await editRef("actionqueue", "RowId", rowId, update);
31
31
 
32
- resolve(updated);
33
- } catch (error) {
34
- reject(error);
35
- }
36
- });
32
+ resolve(updated);
33
+ } catch (error) {
34
+ reject(error);
35
+ }
36
+ });
37
37
  };
@@ -2,24 +2,24 @@ const _ = require("lodash");
2
2
  const getRef = require("../common/getRef");
3
3
 
4
4
  module.exports = async (id, defaultSite) => {
5
- return new Promise((resolve) => {
6
- getRef("strings", "RowId", id)
7
- .then((ev) => {
8
- return resolve(ev.Value);
9
- })
10
- .catch(() => {
11
- if (defaultSite) {
12
- const defaultId = `${defaultSite}_${id.split("_")[1]}`;
13
- getRef("strings", "RowId", defaultId)
14
- .then((ev) => {
15
- return resolve(ev.Value);
16
- })
17
- .catch(() => {
18
- return resolve(null);
19
- });
20
- } else {
21
- return resolve(null);
22
- }
23
- });
24
- });
5
+ return new Promise((resolve) => {
6
+ getRef("strings", "RowId", id)
7
+ .then((ev) => {
8
+ return resolve(ev.Value);
9
+ })
10
+ .catch(() => {
11
+ if (defaultSite) {
12
+ const defaultId = `${defaultSite}_${id.split("_")[1]}`;
13
+ getRef("strings", "RowId", defaultId)
14
+ .then((ev) => {
15
+ return resolve(ev.Value);
16
+ })
17
+ .catch(() => {
18
+ return resolve(null);
19
+ });
20
+ } else {
21
+ return resolve(null);
22
+ }
23
+ });
24
+ });
25
25
  };
@@ -3,22 +3,22 @@ const { getRowId, log } = require("../../helper");
3
3
  const updateRef = require("../common/updateRef");
4
4
 
5
5
  module.exports = (site, entity) => {
6
- return new Promise((resolve, reject) => {
7
- const key = `update-${entity}`;
8
- const entry = {
9
- Site: site,
10
- StringId: key,
11
- Value: moment().valueOf(),
12
- RowId: getRowId(site, key),
13
- };
14
- updateRef("strings", entry)
15
- .then((data) => {
16
- log("logUpdate", "Logged", data);
17
- return resolve(data);
18
- })
19
- .catch((error) => {
20
- log("logUpdate", "Error", error);
21
- return reject(error);
22
- });
23
- });
6
+ return new Promise((resolve, reject) => {
7
+ const key = `update-${entity}`;
8
+ const entry = {
9
+ Site: site,
10
+ StringId: key,
11
+ Value: moment().valueOf(),
12
+ RowId: getRowId(site, key),
13
+ };
14
+ updateRef("strings", entry)
15
+ .then((data) => {
16
+ log("logUpdate", "Logged", data);
17
+ return resolve(data);
18
+ })
19
+ .catch((error) => {
20
+ log("logUpdate", "Error", error);
21
+ return reject(error);
22
+ });
23
+ });
24
24
  };
@@ -1,5 +1,5 @@
1
1
  const getRef = require("../common/getRef");
2
2
 
3
3
  module.exports = async (rowId) => {
4
- return await getRef("templates", "RowId", rowId);
4
+ return await getRef("templates", "RowId", rowId);
5
5
  };
@@ -1,15 +1,15 @@
1
1
  const indexQuery = require("../common/indexQuery");
2
2
 
3
3
  module.exports = async (site, featureKey) => {
4
- const query = {
5
- IndexName: "SiteFeatureKeyIndex",
6
- KeyConditionExpression: "Site = :site AND FeatureKey = :featureKey",
7
- ExpressionAttributeValues: {
8
- ":site": site,
9
- ":featureKey": featureKey,
10
- },
11
- };
4
+ const query = {
5
+ IndexName: "SiteFeatureKeyIndex",
6
+ KeyConditionExpression: "Site = :site AND FeatureKey = :featureKey",
7
+ ExpressionAttributeValues: {
8
+ ":site": site,
9
+ ":featureKey": featureKey,
10
+ },
11
+ };
12
12
 
13
- const { Items } = await indexQuery("templates", query);
14
- return Items;
13
+ const { Items } = await indexQuery("templates", query);
14
+ return Items;
15
15
  };
@@ -3,14 +3,14 @@ const moment = require("moment");
3
3
  const editRef = require("../common/editRef");
4
4
 
5
5
  module.exports = async (rowId, update) => {
6
- const now = moment().valueOf();
7
- const { Updated } = update;
8
- if (!rowId) {
9
- rowId = uuid.v1();
10
- if (!update.Created) update.Created = now;
11
- } else {
12
- if (!Updated) update.Updated = now;
13
- }
6
+ const now = moment().valueOf();
7
+ const { Updated } = update;
8
+ if (!rowId) {
9
+ rowId = uuid.v1();
10
+ if (!update.Created) update.Created = now;
11
+ } else {
12
+ if (!Updated) update.Updated = now;
13
+ }
14
14
 
15
- return await editRef("templates", "RowId", rowId, update);
15
+ return await editRef("templates", "RowId", rowId, update);
16
16
  };
@@ -2,5 +2,5 @@ const { getRowId } = require("../../helper");
2
2
  const getRef = require("../common/getRef");
3
3
 
4
4
  module.exports = async (site, id) => {
5
- return await getRef("roles", "RowId", getRowId(site, id));
5
+ return await getRef("roles", "RowId", getRowId(site, id));
6
6
  };
@@ -1,13 +1,13 @@
1
1
  const getRef = require("../common/getRef");
2
2
 
3
3
  module.exports = (key) => {
4
- return new Promise((resolve, reject) => {
5
- getRef("users", "Id", key)
6
- .then((user) => {
7
- resolve(user);
8
- })
9
- .catch((error) => {
10
- reject(error);
11
- });
12
- });
4
+ return new Promise((resolve, reject) => {
5
+ getRef("users", "Id", key)
6
+ .then((user) => {
7
+ resolve(user);
8
+ })
9
+ .catch((error) => {
10
+ reject(error);
11
+ });
12
+ });
13
13
  };
@@ -3,21 +3,21 @@ const { log } = require("../../helper");
3
3
  const indexQuery = require("../common/indexQuery");
4
4
 
5
5
  module.exports = async (email) => {
6
- return new Promise(async (resolve, reject) => {
7
- const logId = log("getUserByEmail", "email", email);
8
- const query = {
9
- IndexName: "UserValidateIndexEmail",
10
- KeyConditionExpression: "email = :email",
11
- ExpressionAttributeValues: {
12
- ":email": email.toLowerCase(),
13
- },
14
- };
15
- const qResult = await indexQuery("users", query);
16
- if (_.isEmpty(qResult.Items)) {
17
- log("getUserByEmail", "result", null, logId);
18
- return resolve(null);
19
- }
20
- log("getUserByEmail", "result", qResult.Items[0], logId);
21
- return resolve(qResult.Items[0]);
22
- });
6
+ return new Promise(async (resolve, reject) => {
7
+ const logId = log("getUserByEmail", "email", email);
8
+ const query = {
9
+ IndexName: "UserValidateIndexEmail",
10
+ KeyConditionExpression: "email = :email",
11
+ ExpressionAttributeValues: {
12
+ ":email": email.toLowerCase(),
13
+ },
14
+ };
15
+ const qResult = await indexQuery("users", query);
16
+ if (_.isEmpty(qResult.Items)) {
17
+ log("getUserByEmail", "result", null, logId);
18
+ return resolve(null);
19
+ }
20
+ log("getUserByEmail", "result", qResult.Items[0], logId);
21
+ return resolve(qResult.Items[0]);
22
+ });
23
23
  };
@@ -5,34 +5,34 @@ const getMatchingTags = require("./getMatchingTags");
5
5
  const isValidAudience = require("./isValidAudience");
6
6
 
7
7
  module.exports = async (items, authkey, site) => {
8
- const validTypes = await getMatchingAudienceTypes(authkey);
9
- let validTags = [];
10
- if (site) {
11
- const userId = await getSessionUser(authkey);
12
- validTags = await getMatchingTags(userId, site);
13
- }
8
+ const validTypes = await getMatchingAudienceTypes(authkey);
9
+ let validTags = [];
10
+ if (site) {
11
+ const userId = await getSessionUser(authkey);
12
+ validTags = await getMatchingTags(userId, site);
13
+ }
14
14
 
15
- return _.filter(items, (item) => {
16
- if (!item.AudienceType) return true;
15
+ return _.filter(items, (item) => {
16
+ if (!item.AudienceType) return true;
17
17
 
18
- if (item.AudienceType === "Custom") {
19
- return _.some(item.AudienceTypeSelection, (at) =>
20
- isValidAudience(
21
- site,
22
- at.AudienceType,
23
- at.AudienceTypeSelection,
24
- validTypes,
25
- validTags
26
- )
27
- );
28
- }
18
+ if (item.AudienceType === "Custom") {
19
+ return _.some(item.AudienceTypeSelection, (at) =>
20
+ isValidAudience(
21
+ site,
22
+ at.AudienceType,
23
+ at.AudienceTypeSelection,
24
+ validTypes,
25
+ validTags,
26
+ ),
27
+ );
28
+ }
29
29
 
30
- return isValidAudience(
31
- site,
32
- item.AudienceType,
33
- item.AudienceTypeSelection,
34
- validTypes,
35
- validTags
36
- );
37
- });
30
+ return isValidAudience(
31
+ site,
32
+ item.AudienceType,
33
+ item.AudienceTypeSelection,
34
+ validTypes,
35
+ validTags,
36
+ );
37
+ });
38
38
  };
@@ -4,33 +4,33 @@ const getMatchingTags = require("./getMatchingTags");
4
4
  const isValidAudience = require("./isValidAudience");
5
5
 
6
6
  module.exports = async (items, validTypes, authkey, site) => {
7
- let validTags = [];
8
- if (authkey) {
9
- const userId = await getSessionUser(authkey);
10
- validTags = await getMatchingTags(userId, site);
11
- }
7
+ let validTags = [];
8
+ if (authkey) {
9
+ const userId = await getSessionUser(authkey);
10
+ validTags = await getMatchingTags(userId, site);
11
+ }
12
12
 
13
- return _.filter(items, (item) => {
14
- if (!item.AudienceType) return true;
13
+ return _.filter(items, (item) => {
14
+ if (!item.AudienceType) return true;
15
15
 
16
- if (item.AudienceType === "Custom") {
17
- return _.some(item.AudienceTypeSelection, (at) =>
18
- isValidAudience(
19
- site,
20
- at.AudienceType,
21
- at.AudienceTypeSelection,
22
- validTypes,
23
- validTags
24
- )
25
- );
26
- }
16
+ if (item.AudienceType === "Custom") {
17
+ return _.some(item.AudienceTypeSelection, (at) =>
18
+ isValidAudience(
19
+ site,
20
+ at.AudienceType,
21
+ at.AudienceTypeSelection,
22
+ validTypes,
23
+ validTags,
24
+ ),
25
+ );
26
+ }
27
27
 
28
- return isValidAudience(
29
- site,
30
- item.AudienceType,
31
- item.AudienceTypeSelection,
32
- validTypes,
33
- validTags
34
- );
35
- });
28
+ return isValidAudience(
29
+ site,
30
+ item.AudienceType,
31
+ item.AudienceTypeSelection,
32
+ validTypes,
33
+ validTags,
34
+ );
35
+ });
36
36
  };