@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.
- 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 +69 -37
- 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/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 +337 -0
- package/helper/index.js +28 -28
- package/helper/notifySiteConfigs.js +132 -0
- 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 +35 -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
package/db/common/editRef.js
CHANGED
|
@@ -4,43 +4,43 @@ const updateRef = require("./updateRef");
|
|
|
4
4
|
const { log, generateLogId } = require("../../helper");
|
|
5
5
|
|
|
6
6
|
module.exports = async (table, keyCol, id, updates) => {
|
|
7
|
-
|
|
7
|
+
const cloneUpdates = _.cloneDeep(updates);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const logId = generateLogId();
|
|
11
|
+
updates[keyCol] = id;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
// log("editRef", "Params", { table, keyCol, id, updates }, logId);
|
|
14
|
+
getRef(table, keyCol, id)
|
|
15
|
+
.then((item) => {
|
|
16
|
+
// log("editRef", "GotItem", item);
|
|
17
|
+
Object.keys(cloneUpdates).forEach((key) => {
|
|
18
|
+
item[key] = cloneUpdates[key];
|
|
19
|
+
});
|
|
20
|
+
updateRef(table, item)
|
|
21
|
+
.then((res) => {
|
|
22
|
+
// log("editRef", "Result", res, logId);
|
|
23
|
+
resolve(res);
|
|
24
|
+
})
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
log("editRef", "Error", error, logId);
|
|
27
|
+
reject(error);
|
|
28
|
+
});
|
|
29
|
+
})
|
|
30
|
+
.catch((error) => {
|
|
31
|
+
// log("editRef", "NoEntry", "Existing entry doesn't exist", logId);
|
|
32
|
+
cloneUpdates[keyCol] = id;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
// insert if doesn't exit
|
|
35
|
+
updateRef(table, cloneUpdates)
|
|
36
|
+
.then((res) => {
|
|
37
|
+
// log("editRef", "Result", res, logId);
|
|
38
|
+
resolve(res);
|
|
39
|
+
})
|
|
40
|
+
.catch((error) => {
|
|
41
|
+
log("editRef", "Error", error, logId);
|
|
42
|
+
reject(error);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
46
|
};
|
package/db/common/getRef.js
CHANGED
|
@@ -3,29 +3,29 @@ const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
|
3
3
|
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = async (table, key, value) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
8
|
+
try {
|
|
9
|
+
const query = {
|
|
10
|
+
TableName: `${process.env.tablePrefix}${table}`,
|
|
11
|
+
Key: {},
|
|
12
|
+
};
|
|
13
|
+
query.Key[key] = value;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// log("getRef", "Query", query, logId);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
dynamoDb.get(query, (error, data) => {
|
|
18
|
+
if (error) {
|
|
19
|
+
log("getRef", "Error", error, logId);
|
|
20
|
+
reject(error);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// log("getRef", "Success", data.Item, logId);
|
|
24
|
+
resolve(data.Item);
|
|
25
|
+
return;
|
|
26
|
+
});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
log("getRef", "Error:Caught", e, logId);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
31
|
};
|
|
@@ -3,23 +3,23 @@ const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
|
3
3
|
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = (table) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
8
|
+
const query = {
|
|
9
|
+
TableName: `${process.env.tablePrefix}${table}`,
|
|
10
|
+
Select: "COUNT",
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
dynamoDb.scan(query, (error, result) => {
|
|
14
|
+
// handle potential errors
|
|
15
|
+
if (error) {
|
|
16
|
+
log("getTableCount", "Error", error, logId);
|
|
17
|
+
reject();
|
|
18
|
+
return;
|
|
19
|
+
} else {
|
|
20
|
+
resolve(result);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
25
|
};
|
package/db/common/indexQuery.js
CHANGED
|
@@ -3,23 +3,23 @@ const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
|
3
3
|
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = async (table, query) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
8
|
+
query.TableName = `${process.env.tablePrefix}${table}`;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// log("indexQuery", "Query", JSON.stringify(query), logId);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
// write the todo to the database
|
|
13
|
+
dynamoDb.query(query, (error, data) => {
|
|
14
|
+
// handle potential errors
|
|
15
|
+
if (error) {
|
|
16
|
+
log("indexQuery", "Error", error, logId);
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// log("indexQuery", "ResultLength", data.Items.length, logId);
|
|
21
|
+
resolve(data);
|
|
22
|
+
return;
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
25
|
};
|
|
@@ -2,28 +2,28 @@ const _ = require("lodash");
|
|
|
2
2
|
const indexQuery = require("./indexQuery");
|
|
3
3
|
|
|
4
4
|
const indexQueryRecursive = (table, query, result, tempResult) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
if (!tempResult) {
|
|
7
|
+
tempResult = [];
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
if (result) {
|
|
11
|
+
tempResult = _.concat(tempResult, result.Items);
|
|
12
|
+
if (!result.LastEvaluatedKey) {
|
|
13
|
+
return resolve(tempResult);
|
|
14
|
+
} else {
|
|
15
|
+
query.ExclusiveStartKey = result.LastEvaluatedKey;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
indexQuery(table, query).then((queryResult) => {
|
|
20
|
+
indexQueryRecursive(table, query, queryResult, tempResult).then(
|
|
21
|
+
(innerRes) => {
|
|
22
|
+
resolve(innerRes);
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
module.exports = indexQueryRecursive;
|
package/db/common/scanRef.js
CHANGED
|
@@ -2,23 +2,23 @@ const AWS = require("aws-sdk");
|
|
|
2
2
|
const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
3
3
|
|
|
4
4
|
module.exports = (table, query) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
if (!query) {
|
|
7
|
+
query = {};
|
|
8
|
+
}
|
|
9
|
+
query.TableName = `${process.env.tablePrefix}${table}`;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
dynamoDb.scan(query, (error, result) => {
|
|
12
|
+
// handle potential errors
|
|
13
|
+
if (error) {
|
|
14
|
+
console.error(`Table Scan fail: ${table}`);
|
|
15
|
+
console.error(error);
|
|
16
|
+
reject();
|
|
17
|
+
return;
|
|
18
|
+
} else {
|
|
19
|
+
resolve(result);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
24
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
const scanRef = require("./scanRef");
|
|
2
2
|
|
|
3
3
|
const scanRefRecursive = async (tableName, query, startKey) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
if (!query) {
|
|
5
|
+
query = {};
|
|
6
|
+
}
|
|
7
|
+
// Set the ExclusiveStartKey in the params
|
|
8
|
+
query.ExclusiveStartKey = startKey;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Perform the scan and await the results
|
|
11
|
+
const data = await scanRef(tableName, query);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// Extract the Items from the results
|
|
14
|
+
let items = data.Items;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
// If the LastEvaluatedKey is present, that means there are more items to fetch
|
|
17
|
+
if (data.LastEvaluatedKey) {
|
|
18
|
+
// Recursively call the function to fetch the next batch of items, and await the results
|
|
19
|
+
// Concatenate the new items with the ones we have already fetched
|
|
20
|
+
items = [
|
|
21
|
+
...items,
|
|
22
|
+
...(await scanRefRecursive(tableName, query, data.LastEvaluatedKey)),
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Return the complete list of items
|
|
27
|
+
return items;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
module.exports = scanRefRecursive;
|
|
@@ -3,33 +3,33 @@ const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
|
3
3
|
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
table,
|
|
7
|
+
tableKey,
|
|
8
|
+
tableValue,
|
|
9
|
+
attributeKey,
|
|
10
|
+
attributeValue,
|
|
11
|
+
action,
|
|
12
12
|
) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const logId = generateLogId();
|
|
15
|
+
const params = {
|
|
16
|
+
TableName: `${process.env.tablePrefix}${table}`,
|
|
17
|
+
Key: {
|
|
18
|
+
[tableKey]: tableValue,
|
|
19
|
+
},
|
|
20
|
+
AttributeUpdates: {
|
|
21
|
+
[attributeKey]: { Action: action, Value: attributeValue },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
// log("updateAttribute", "Params", params, logId);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
dynamoDb.update(params, (err, data) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
log("updateAttribute", "Error", err, logId);
|
|
29
|
+
return reject(err);
|
|
30
|
+
}
|
|
31
|
+
// log("updateAttribute", "Success", data, logId);
|
|
32
|
+
return resolve(data);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
35
|
};
|
package/db/common/updateRef.js
CHANGED
|
@@ -3,26 +3,26 @@ const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
|
3
3
|
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = async (table, data) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
8
|
+
const params = {
|
|
9
|
+
TableName: `${process.env.tablePrefix}${table}`,
|
|
10
|
+
Item: data,
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// log("updateRef", "Params", params, logId);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
// write the todo to the database
|
|
16
|
+
dynamoDb.put(params, (error) => {
|
|
17
|
+
// handle potential errors
|
|
18
|
+
if (error) {
|
|
19
|
+
log("updateRef", "Error", error, logId);
|
|
20
|
+
reject(error);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// log("updateRef", "Result", data, logId);
|
|
24
|
+
resolve(data);
|
|
25
|
+
return;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
28
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const indexQuery = require("../common/indexQuery");
|
|
2
2
|
|
|
3
3
|
module.exports = (userID) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const query = {
|
|
6
|
+
IndexName: "LinkedByLinkedUserIdIndex",
|
|
7
|
+
KeyConditionExpression: "LinkedUserId = :userID",
|
|
8
|
+
ExpressionAttributeValues: {
|
|
9
|
+
":userID": userID,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
console.log("running linkedUserId query");
|
|
14
|
+
console.log(query);
|
|
15
|
+
indexQuery("linkedusers", query)
|
|
16
|
+
.then((data) => {
|
|
17
|
+
console.log("successful query");
|
|
18
|
+
resolve(data);
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
console.log("query failed");
|
|
22
|
+
console.log(error);
|
|
23
|
+
reject();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
26
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const indexQuery = require("../common/indexQuery");
|
|
2
2
|
|
|
3
3
|
module.exports = (userID) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const query = {
|
|
6
|
+
IndexName: "LinkedByUserIdIndex",
|
|
7
|
+
KeyConditionExpression: "UserId = :userID",
|
|
8
|
+
ExpressionAttributeValues: {
|
|
9
|
+
":userID": userID,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
console.log("running linkedUserId query");
|
|
14
|
+
console.log(query);
|
|
15
|
+
indexQuery("linkedusers", query)
|
|
16
|
+
.then((data) => {
|
|
17
|
+
console.log("successful query");
|
|
18
|
+
resolve(data);
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
console.log("query failed");
|
|
22
|
+
console.log(error);
|
|
23
|
+
reject();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
26
|
};
|
|
@@ -2,28 +2,28 @@ const indexQuery = require("../common/indexQuery");
|
|
|
2
2
|
const deleteRef = require("../common/deleteRef");
|
|
3
3
|
|
|
4
4
|
module.exports = async (entityId, type = null, site = null) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const query = {
|
|
6
|
+
IndexName: "NotificationsIdIndex",
|
|
7
|
+
KeyConditionExpression: "Id = :entityId",
|
|
8
|
+
ExpressionAttributeValues: {
|
|
9
|
+
":entityId": entityId,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
let toDelete = [];
|
|
14
|
+
const { Items } = await indexQuery("notifications", query);
|
|
15
|
+
if (type || site) {
|
|
16
|
+
toDelete = Items.filter(
|
|
17
|
+
(i) => (!type || i.Type === type) && (!site || i.Site === site),
|
|
18
|
+
);
|
|
19
|
+
} else {
|
|
20
|
+
toDelete = Items;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const promises = [];
|
|
24
|
+
toDelete.forEach((i) => {
|
|
25
|
+
promises.push(deleteRef("notifications", "RowId", i.RowId));
|
|
26
|
+
});
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
return Promise.all(promises);
|
|
29
29
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
const indexQuery = require("../common/indexQuery");
|
|
2
2
|
|
|
3
3
|
module.exports = async (userId, type = null, id = null) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
const query = {
|
|
5
|
+
IndexName: "UserIndex",
|
|
6
|
+
KeyConditionExpression: "UserId = :userId",
|
|
7
|
+
ExpressionAttributeValues: {
|
|
8
|
+
":userId": userId,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
const { Items } = await indexQuery("notificationsettings", query);
|
|
12
|
+
if (type) {
|
|
13
|
+
return Items.find(
|
|
14
|
+
(i) => i.EntityType === type && (!id || i.EntityId === id),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return Items;
|
|
18
18
|
};
|