@plusscommunities/pluss-core-aws 2.0.9 → 2.0.10
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,29 @@
|
|
|
1
|
+
const indexQuery = require("../common/indexQuery");
|
|
2
|
+
const deleteRef = require("../common/deleteRef");
|
|
3
|
+
|
|
4
|
+
module.exports = async (entityId, type = null, site = null) => {
|
|
5
|
+
const query = {
|
|
6
|
+
IndexName: "NotificationsIdIndex",
|
|
7
|
+
KeyConditionExpression: "Id = :entityId",
|
|
8
|
+
ExpressionAttributeValues: {
|
|
9
|
+
":entityId": entityId,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
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
|
+
|
|
23
|
+
const promises = [];
|
|
24
|
+
toDelete.forEach((i) => {
|
|
25
|
+
promises.push(deleteRef("notifications", "RowId", i.RowId));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return Promise.all(promises);
|
|
29
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const getRef = require("../../db/common/getRef");
|
|
2
1
|
const getSessionUser = require("./getSessionUser");
|
|
2
|
+
const getApiKeyFromReq = require("./getApiKeyFromReq");
|
|
3
3
|
|
|
4
4
|
module.exports = async (event) => {
|
|
5
5
|
if (!event.headers) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
if (event.headers.apikey) {
|
|
9
|
-
const key = await
|
|
10
|
-
return key
|
|
9
|
+
const key = await getApiKeyFromReq(event);
|
|
10
|
+
return key?.UserId;
|
|
11
11
|
}
|
|
12
12
|
if (!event.headers.authkey) {
|
|
13
13
|
return null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const _ = require("lodash");
|
|
2
2
|
const { log, generateLogId } = require("../");
|
|
3
|
-
const
|
|
3
|
+
const getApiKeyFromReq = require("./getApiKeyFromReq");
|
|
4
4
|
|
|
5
5
|
module.exports = async (req, actionType, site) => {
|
|
6
6
|
const logId = generateLogId();
|
|
7
7
|
try {
|
|
8
8
|
log("ApiKey", "Input", req.headers.apikey, logId);
|
|
9
|
-
const key = await
|
|
9
|
+
const key = await getApiKeyFromReq(req);
|
|
10
10
|
log("ApiKey", "Key", key, logId);
|
|
11
11
|
|
|
12
12
|
if (key.UserId) {
|