@plusscommunities/pluss-core-aws 2.0.26-auth.0 → 2.0.26
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.
- package/aws/getDefaultEmailAddress.js +21 -21
- package/aws/getEmailService.js +16 -16
- package/aws/getEmailServiceInfo.js +26 -26
- package/aws/sendEmail.js +31 -31
- package/config.js +1 -1
- package/db/activity/publishActivity.js +22 -22
- package/db/analytics/checkActivityExists.js +15 -15
- package/db/analytics/logAnalyticsActivity.js +104 -40
- package/db/analytics/scheduleOldAggregation.js +14 -14
- package/db/auth/getSiteSetting.js +12 -12
- package/db/auth/getSiteUserTypes.js +16 -16
- package/db/auth/getUserAuth.js +13 -13
- package/db/automatedactions/getActionBySiteTrigger.js +9 -9
- package/db/common/deleteRef.js +21 -21
- package/db/common/editRef.js +36 -36
- package/db/common/getRef.js +23 -23
- package/db/common/getTableCount.js +18 -18
- package/db/common/indexQuery.js +17 -17
- package/db/common/indexQueryRecursive.js +20 -20
- package/db/common/scanRef.js +18 -18
- package/db/common/scanRefRecursive.js +20 -20
- package/db/common/updateAttribute.js +27 -27
- package/db/common/updateRef.js +20 -20
- package/db/linkedUsers/getLinkedBy.js +21 -21
- package/db/linkedUsers/getLinkedTo.js +21 -21
- package/db/notifications/deleteNotificationsByEntity.js +21 -21
- package/db/notifications/getNotificationSetting.js +14 -14
- package/db/notifications/publishNotifications.js +39 -39
- package/db/postgres/getKnex.js +214 -0
- package/db/postgres/safeError.js +40 -0
- package/db/property/Property.js +128 -0
- package/db/property/PropertyRepository.js +86 -0
- package/db/scheduledActions/deleteActionQueue.js +1 -1
- package/db/scheduledActions/getActionQueueByEntityId.js +10 -10
- package/db/scheduledActions/getActionQueueByEntityKey.js +9 -9
- package/db/scheduledActions/getActionQueueById.js +9 -9
- package/db/scheduledActions/getActionQueueByTriggerAt.js +14 -14
- package/db/scheduledActions/updateActionQueue.js +29 -29
- package/db/strings/getString.js +20 -20
- package/db/strings/logUpdate.js +18 -18
- package/db/templates/getTemplateById.js +1 -1
- package/db/templates/getTemplatesList.js +10 -10
- package/db/templates/updateTemplate.js +9 -9
- package/db/users/getRole.js +1 -1
- package/db/users/getUser.js +9 -9
- package/db/users/getUserByEmail.js +17 -17
- package/helper/audience/filterByAudienceType.js +27 -27
- package/helper/audience/filterOnAudienceType.js +26 -26
- package/helper/audience/getAudience.js +187 -187
- package/helper/audience/getMatchingAudienceTypes.js +21 -21
- package/helper/audience/getMatchingAudienceTypesFromPreview.js +60 -60
- package/helper/audience/getMatchingTags.js +15 -15
- package/helper/audience/isValidAudience.js +20 -20
- package/helper/auth/checkTokenBlacklist.js +17 -17
- package/helper/auth/getApiKeyFromReq.js +2 -2
- package/helper/auth/getSessionUser.js +70 -85
- package/helper/auth/getSessionUserFromReq.js +2 -2
- package/helper/auth/getSessionUserFromReqAuthKey.js +11 -11
- package/helper/auth/validateApiKey.js +32 -32
- package/helper/auth/validateMasterAuth.js +174 -174
- package/helper/auth/validateSiteAccess.js +12 -12
- package/helper/auth/validateSiteSetting.js +7 -7
- package/helper/auth/validateUserLoggedIn.js +19 -19
- package/helper/createGuid.js +5 -5
- package/helper/generateJsonResponse.js +27 -27
- package/helper/getUserPreview.js +57 -57
- package/helper/getUserPreviewFromHeader.js +17 -17
- package/helper/getUserPreviewFromReq.js +17 -17
- package/helper/hqPublishing.js +465 -0
- package/helper/index.js +28 -28
- package/helper/notifySiteConfigs.js +67 -52
- package/helper/opengraph/getOpenGraph.js +12 -12
- package/helper/rates/checkRateLimit.js +38 -38
- package/helper/requestToSource.js +10 -10
- package/helper/sendEmail.js +120 -120
- package/helper/templates/replacePlaceHolders.js +29 -29
- package/helper/time/getLocalTimestamp.js +18 -18
- package/helper/time/getSiteTimezone.js +11 -11
- package/helper/triggerAutomatedAction.js +25 -25
- package/helper/userToUserPreview.js +23 -23
- package/helper/users/getUserTypesByPermission.js +24 -24
- package/helper/users/getUsersByPermission.js +20 -20
- package/notification/prepNotification.js +144 -144
- package/notification/sendNotifications.js +166 -166
- package/package.json +37 -40
- package/templates/supportTicketEmails.js +8 -8
- package/helper/auth/context/AuthenticationContext.js +0 -50
- package/helper/auth/context/AuthenticationStrategy.js +0 -20
- package/helper/auth/context/auth0/Strategy.js +0 -12
- package/helper/auth/context/auth0/functions/decodeAccessToken.js +0 -102
- package/helper/auth/context/auth0/functions/getSessionUser.js +0 -21
- package/helper/auth/context/boltonclarke/Strategy.js +0 -10
- package/helper/auth/context/cognito/Strategy.js +0 -12
- package/helper/auth/context/cognito/functions/getSessionUser.js +0 -76
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
|
|
3
3
|
module.exports = (accessKey, secretKey) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
if (accessKey && secretKey) {
|
|
6
|
+
AWS.config.update({
|
|
7
|
+
accessKeyId: accessKey,
|
|
8
|
+
secretAccessKey: secretKey,
|
|
9
|
+
});
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
const sesv2 = new AWS.SESV2();
|
|
12
|
+
const params = { PageSize: 1 };
|
|
13
|
+
sesv2.listEmailIdentities(params, (err, data) => {
|
|
14
|
+
if (err) return reject(err);
|
|
15
|
+
const { EmailIdentities } = data;
|
|
16
|
+
return resolve(
|
|
17
|
+
EmailIdentities && EmailIdentities.length > 0
|
|
18
|
+
? EmailIdentities[0]
|
|
19
|
+
: null,
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
resolve(null);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
26
|
};
|
package/aws/getEmailService.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
|
|
3
3
|
module.exports = (accessKey, secretKey) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
if (accessKey && secretKey) {
|
|
6
|
+
AWS.config.update({
|
|
7
|
+
accessKeyId: accessKey,
|
|
8
|
+
secretAccessKey: secretKey,
|
|
9
|
+
});
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const sesv2 = new AWS.SESV2();
|
|
12
|
+
const params = {};
|
|
13
|
+
sesv2.getAccount(params, (err, data) => {
|
|
14
|
+
if (err) return reject(err);
|
|
15
|
+
return resolve(data);
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
resolve(null);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
21
|
};
|
|
@@ -3,31 +3,31 @@ const getDefaultEmailAddress = require("./getDefaultEmailAddress");
|
|
|
3
3
|
const { getConfig } = require("../config");
|
|
4
4
|
|
|
5
5
|
module.exports = async (accessKey, secretKey) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
const result = {
|
|
7
|
+
enabled: false,
|
|
8
|
+
sender: null,
|
|
9
|
+
};
|
|
10
|
+
const { emailConfig } = getConfig();
|
|
11
|
+
const service = await getEmailService(accessKey, secretKey);
|
|
12
|
+
console.log("Amazon SES status", {
|
|
13
|
+
service,
|
|
14
|
+
allwoSandbox: emailConfig.allwoSandbox,
|
|
15
|
+
forceFallback: emailConfig.forceFallback,
|
|
16
|
+
});
|
|
17
|
+
if (emailConfig.forceFallback) return result;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
if (
|
|
20
|
+
service &&
|
|
21
|
+
service.SendingEnabled &&
|
|
22
|
+
(emailConfig.allwoSandbox || service.ProductionAccessEnabled) &&
|
|
23
|
+
service.SendQuota.Max24HourSend > service.SendQuota.SentLast24Hours
|
|
24
|
+
) {
|
|
25
|
+
result.enabled = true;
|
|
26
|
+
const sender = await getDefaultEmailAddress(accessKey, secretKey);
|
|
27
|
+
console.log("Amazon SES sender", sender);
|
|
28
|
+
if (sender) {
|
|
29
|
+
result.sender = sender.IdentityName;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
33
|
};
|
package/aws/sendEmail.js
CHANGED
|
@@ -2,36 +2,36 @@ const AWS = require("aws-sdk");
|
|
|
2
2
|
const { getConfig } = require("../config");
|
|
3
3
|
|
|
4
4
|
module.exports = (from, to, subject, content, access = null, bcc = null) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const { serverlessConfig } = getConfig();
|
|
7
|
+
AWS.config.update({
|
|
8
|
+
accessKeyId: access ? access.key : serverlessConfig.key,
|
|
9
|
+
secretAccessKey: access ? access.secret : serverlessConfig.secret,
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
const sesv2 = new AWS.SESV2();
|
|
13
|
+
const params = {
|
|
14
|
+
Content: {
|
|
15
|
+
Simple: {
|
|
16
|
+
Body: {
|
|
17
|
+
Html: {
|
|
18
|
+
Data: content,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
Subject: {
|
|
22
|
+
Data: subject,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
Destination: {
|
|
27
|
+
ToAddresses: to.split(",").map((i) => i.trim()),
|
|
28
|
+
BccAddresses: bcc ? bcc.split(",").map((i) => i.trim()) : [],
|
|
29
|
+
},
|
|
30
|
+
FromEmailAddress: from,
|
|
31
|
+
};
|
|
32
|
+
sesv2.sendEmail(params, (err, data) => {
|
|
33
|
+
if (err) return reject(err);
|
|
34
|
+
return resolve(data);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
37
|
};
|
package/config.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
const moment = require(
|
|
2
|
-
const updateRef = require(
|
|
3
|
-
const { getMultiRowId } = require(
|
|
1
|
+
const moment = require("moment");
|
|
2
|
+
const updateRef = require("../common/updateRef");
|
|
3
|
+
const { getMultiRowId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = (type, site, id, user, data) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const activity = {};
|
|
8
|
+
const timestamp = moment.utc();
|
|
9
|
+
activity.Timestamp = timestamp.toISOString();
|
|
10
|
+
activity.UnixTimestamp = timestamp.unix();
|
|
11
|
+
activity.Type = type;
|
|
12
|
+
activity.Site = site;
|
|
13
|
+
activity.Id = id;
|
|
14
|
+
activity.User = user;
|
|
15
|
+
activity.RowId = getMultiRowId([site, type, id, user.id]);
|
|
16
|
+
activity.Data = data;
|
|
17
|
+
updateRef(`adminactivity`, activity)
|
|
18
|
+
.then(() => {
|
|
19
|
+
resolve();
|
|
20
|
+
})
|
|
21
|
+
.catch((error) => {
|
|
22
|
+
reject(error);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
24
25
|
};
|
|
25
|
-
|
|
@@ -11,19 +11,19 @@ const indexQuery = require("../common/indexQuery");
|
|
|
11
11
|
* @returns Whether there is any matching analytics activity
|
|
12
12
|
*/
|
|
13
13
|
module.exports = async (entityId, entityType, actionType, userId) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
const result = await indexQuery("analytics", {
|
|
15
|
+
IndexName: "AnalyticsActivityIndex",
|
|
16
|
+
KeyConditionExpression: "ActivityId = :activityId",
|
|
17
|
+
ExpressionAttributeValues: {
|
|
18
|
+
":activityId": getMultiRowId([entityId, entityType, actionType]),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
if (result && !_.isEmpty(result.Items)) {
|
|
22
|
+
if (userId) {
|
|
23
|
+
// check if there is matching analytics activity for that user
|
|
24
|
+
return result.Items.some((item) => item.UserId === userId);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
29
|
};
|
|
@@ -2,7 +2,9 @@ const uuid = require("uuid");
|
|
|
2
2
|
const moment = require("moment");
|
|
3
3
|
const checkActivityExists = require("./checkActivityExists");
|
|
4
4
|
const updateRef = require("../common/updateRef");
|
|
5
|
-
const
|
|
5
|
+
const getRole = require("../users/getRole");
|
|
6
|
+
const getUser = require("../users/getUser");
|
|
7
|
+
const { getMultiRowId, getRowId, log } = require("../../helper");
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Creates an analytics entry
|
|
@@ -18,44 +20,106 @@ const { getMultiRowId, getRowId } = require("../../helper");
|
|
|
18
20
|
* @returns Whether the activity was logged
|
|
19
21
|
*/
|
|
20
22
|
module.exports = async (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
actionType,
|
|
24
|
+
entityType,
|
|
25
|
+
site,
|
|
26
|
+
user,
|
|
27
|
+
entityId,
|
|
28
|
+
data,
|
|
29
|
+
timestamp,
|
|
30
|
+
uniqueActivity,
|
|
31
|
+
uniqueToUser,
|
|
30
32
|
) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
33
|
+
// Check if the activity already exists
|
|
34
|
+
if (uniqueActivity) {
|
|
35
|
+
const exists = await checkActivityExists(
|
|
36
|
+
entityId,
|
|
37
|
+
entityType,
|
|
38
|
+
actionType,
|
|
39
|
+
uniqueToUser && user ? user.id : null,
|
|
40
|
+
);
|
|
41
|
+
if (exists) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Never fail on a missing user — persist with null enrichment.
|
|
47
|
+
const actor = user || {};
|
|
48
|
+
|
|
49
|
+
// Type/category are per-site role facts, so resolve them here — callers only
|
|
50
|
+
// carry minimal user objects.
|
|
51
|
+
let userType = null;
|
|
52
|
+
let userCategory = null;
|
|
53
|
+
let enrichmentFailed = false;
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const role = await getRole(site, actor.id);
|
|
57
|
+
if (role) {
|
|
58
|
+
userType = role.type || null;
|
|
59
|
+
userCategory = role.category || null;
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// Log so an outage is distinguishable from a missing role, then fall
|
|
63
|
+
// through to the master fallback.
|
|
64
|
+
enrichmentFailed = true;
|
|
65
|
+
log("logActivity", "RoleLookupFailed", {
|
|
66
|
+
site,
|
|
67
|
+
userId: actor.id || null,
|
|
68
|
+
err: e,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Master fallback: previews omit type (undefined ≠ the system user's explicit
|
|
73
|
+
// null), so resolve it from the user record.
|
|
74
|
+
let primaryType = actor.type;
|
|
75
|
+
if (!userType && primaryType === undefined && actor.id) {
|
|
76
|
+
try {
|
|
77
|
+
const fullUser = await getUser(actor.id);
|
|
78
|
+
primaryType = fullUser ? fullUser.type : null;
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// Best-effort — log so a lookup failure is distinguishable from a
|
|
81
|
+
// genuinely uncategorised user, but never block the activity write.
|
|
82
|
+
enrichmentFailed = true;
|
|
83
|
+
log("logActivity", "EnrichmentLookupFailed", {
|
|
84
|
+
site,
|
|
85
|
+
userId: actor.id,
|
|
86
|
+
err: e,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!userType && primaryType === "master") {
|
|
91
|
+
userType = "master";
|
|
92
|
+
}
|
|
93
|
+
// Masters count as staff for category filtering.
|
|
94
|
+
if (userType === "master" && !userCategory) {
|
|
95
|
+
userCategory = "staff";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Log the activity
|
|
99
|
+
const activity = {
|
|
100
|
+
Id: uuid.v1(),
|
|
101
|
+
Type: actionType,
|
|
102
|
+
Timestamp: timestamp || moment.utc().valueOf(),
|
|
103
|
+
EntityType: entityType,
|
|
104
|
+
SubjectId: entityId,
|
|
105
|
+
UserId: actor.id || null,
|
|
106
|
+
User: user || null,
|
|
107
|
+
Site: site,
|
|
108
|
+
EntityId: getRowId(entityId, entityType),
|
|
109
|
+
ActivityId: getMultiRowId([entityId, entityType, actionType]),
|
|
110
|
+
Data: data,
|
|
111
|
+
userType,
|
|
112
|
+
userCategory,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// An unresolved lookup failure means enrichment didn't happen — omit the
|
|
116
|
+
// keys so aggregation applies pre-enrichment totals semantics rather than
|
|
117
|
+
// recording a falsely "enriched but uncategorised" event.
|
|
118
|
+
if (enrichmentFailed && userType === null && userCategory === null) {
|
|
119
|
+
delete activity.userType;
|
|
120
|
+
delete activity.userCategory;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
await updateRef(`analytics`, activity);
|
|
124
|
+
return true;
|
|
61
125
|
};
|
|
@@ -2,19 +2,19 @@ const updateRef = require("../common/updateRef");
|
|
|
2
2
|
const { getRowId } = require("../../helper");
|
|
3
3
|
|
|
4
4
|
module.exports = (date, site) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const schedule = {
|
|
7
|
+
Id: getRowId(site, date),
|
|
8
|
+
Date: date,
|
|
9
|
+
Site: site,
|
|
10
|
+
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
updateRef(`analyticsqueue`, schedule)
|
|
13
|
+
.then(() => {
|
|
14
|
+
resolve();
|
|
15
|
+
})
|
|
16
|
+
.catch((error) => {
|
|
17
|
+
reject(error);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
20
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const getRef = require("../common/getRef");
|
|
2
2
|
|
|
3
3
|
module.exports = async (site, key) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
16
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
const indexQuery = require("../common/indexQuery");
|
|
2
2
|
|
|
3
3
|
module.exports = async (site) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const query = {
|
|
6
|
+
IndexName: "UserTypesSiteIndex",
|
|
7
|
+
KeyConditionExpression: "site = :site",
|
|
8
|
+
ExpressionAttributeValues: {
|
|
9
|
+
":site": site,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
indexQuery("usertypes", query)
|
|
14
|
+
.then((res) => {
|
|
15
|
+
resolve(res.Items);
|
|
16
|
+
})
|
|
17
|
+
.catch((error) => {
|
|
18
|
+
reject(error);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
21
|
};
|
package/db/auth/getUserAuth.js
CHANGED
|
@@ -2,17 +2,17 @@ const getRef = require("../common/getRef");
|
|
|
2
2
|
const _ = require("lodash");
|
|
3
3
|
|
|
4
4
|
module.exports = (id) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
getRef("users", "Id", id).then((data) => {
|
|
7
|
+
if (_.isEmpty(data.Roles)) {
|
|
8
|
+
return resolve([
|
|
9
|
+
{
|
|
10
|
+
site: data.site,
|
|
11
|
+
type: data.type,
|
|
12
|
+
},
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
return resolve(data.Roles);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
18
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const indexQuery = require("../common/indexQuery");
|
|
2
2
|
|
|
3
3
|
module.exports = async (site, trigger = null) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const query = {
|
|
5
|
+
IndexName: "SiteIndex",
|
|
6
|
+
KeyConditionExpression: "Site = :site",
|
|
7
|
+
ExpressionAttributeValues: {
|
|
8
|
+
":site": site,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const { Items } = await indexQuery("automatedactions", query);
|
|
13
|
+
return trigger ? Items.filter((i) => i.Trigger === trigger) : Items;
|
|
14
14
|
};
|