@plusscommunities/pluss-newsletter-aws-sharing 2.0.7 → 2.0.8-beta.2
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/package-lock.json +4 -4
- package/package.json +3 -3
- package/watchNewsletter.js +46 -28
package/package-lock.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-newsletter-aws-sharing",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8-beta.2",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -1506,9 +1506,9 @@
|
|
|
1506
1506
|
}
|
|
1507
1507
|
},
|
|
1508
1508
|
"@plusscommunities/pluss-core-aws": {
|
|
1509
|
-
"version": "2.0.
|
|
1510
|
-
"resolved": "https://registry.npmjs.org/@plusscommunities/pluss-core-aws/-/pluss-core-aws-2.0.
|
|
1511
|
-
"integrity": "sha512-
|
|
1509
|
+
"version": "2.0.23-beta.3",
|
|
1510
|
+
"resolved": "https://registry.npmjs.org/@plusscommunities/pluss-core-aws/-/pluss-core-aws-2.0.23-beta.3.tgz",
|
|
1511
|
+
"integrity": "sha512-oBdo29f2w34LXzMa3I0rZJ9TxuSzshRd4Ky7AU/Rnx5jTkSMvd3p0EHsJNUEX5HEukdXItiZmor3tbFxxAilGg==",
|
|
1512
1512
|
"requires": {
|
|
1513
1513
|
"@aws/dynamodb-auto-marshaller": "^0.7.1",
|
|
1514
1514
|
"amazon-cognito-identity-js": "^2.0.19",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-newsletter-aws-sharing",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8-beta.2",
|
|
4
4
|
"description": "Extension package to enable newsletter on Pluss Communities Platform",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"gc": "node ../../tools/gc ./",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"copy:get": "echo $npm_package_name",
|
|
17
17
|
"copy:set": "run(){ target='\\@plusscommunities\\/pluss-newsletter-aws'; ext=${1:-default}; [ $ext == 'default' ] && replace=$target || replace=$target'-'$ext; echo 'Setting target to '$replace; test -f values.config.$ext.js && cp -f values.config.$ext.js values.config.js; sed -i '' -e 's/'$target'.*\"/'$replace'\"/g' package.json; }; run",
|
|
18
18
|
"copy:deploy": "for file in `ls ./values.config.*.js`; do dup=`echo $file | sed 's/.*values\\.config\\.\\(.*\\)\\.js/\\1/'`; npm run copy:set $dup; npm run deploy; done; npm run copy:set; npm run gs;",
|
|
19
|
-
"copy:betaupload": "
|
|
19
|
+
"copy:betaupload": "for file in `ls ./values.config.*.js`; do dup=`echo $file | sed 's/.*values\\.config\\.\\(.*\\)\\.js/\\1/'`; npm run copy:set $dup; npm run betaupload; done; npm run copy:set;",
|
|
20
20
|
"copy:upload": "npm run patch; for file in `ls ./values.config.*.js`; do dup=`echo $file | sed 's/.*values\\.config\\.\\(.*\\)\\.js/\\1/'`; npm run copy:set $dup; npm run upload; done; npm run copy:set;",
|
|
21
21
|
"test": "jest tests -i"
|
|
22
22
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws/dynamodb-auto-marshaller": "^0.7.1",
|
|
27
|
-
"@plusscommunities/pluss-core-aws": "2.0.
|
|
27
|
+
"@plusscommunities/pluss-core-aws": "2.0.23-beta.3",
|
|
28
28
|
"amazon-cognito-identity-js": "^2.0.19",
|
|
29
29
|
"axios": "^1.6.8",
|
|
30
30
|
"aws-sdk": "^2.1591.0",
|
package/watchNewsletter.js
CHANGED
|
@@ -27,13 +27,13 @@ const setUnsentNotification = (update) => {
|
|
|
27
27
|
return;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const sendNotifications = (update) => {
|
|
31
|
-
|
|
30
|
+
const sendNotifications = async (update) => {
|
|
31
|
+
if (!update.Notification) return; // no notification
|
|
32
|
+
if (update.UnsentNotification !== "X") return; // already sent notification
|
|
33
|
+
|
|
34
|
+
try {
|
|
32
35
|
if (update.Private) {
|
|
33
|
-
|
|
34
|
-
return user.userId;
|
|
35
|
-
});
|
|
36
|
-
publishNotifications(
|
|
36
|
+
await publishNotifications(
|
|
37
37
|
update.Tagged.map((user) => {
|
|
38
38
|
return user.userId;
|
|
39
39
|
}),
|
|
@@ -47,24 +47,35 @@ const sendNotifications = (update) => {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
getAudience(
|
|
50
|
+
const audience = await getAudience(
|
|
51
51
|
update.Site,
|
|
52
52
|
update.AudienceType,
|
|
53
53
|
update.AudienceTypeSelection
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
await publishNotifications(
|
|
57
|
+
audience.map((u) => {
|
|
58
|
+
return u.id;
|
|
59
|
+
}),
|
|
60
|
+
values.notificationNewsletterPublished,
|
|
61
|
+
update.Site,
|
|
62
|
+
update.RowId,
|
|
63
|
+
update,
|
|
64
|
+
true
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
setUnsentNotification(update);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("sendNotifications error:", {
|
|
70
|
+
newsletterId: update.RowId,
|
|
71
|
+
site: update.Site,
|
|
72
|
+
title: update.Title,
|
|
73
|
+
error: error.message,
|
|
74
|
+
stack: error.stack,
|
|
66
75
|
});
|
|
67
|
-
|
|
76
|
+
// Don't re-throw - allow other newsletters to process
|
|
77
|
+
// But log the failure so we can investigate
|
|
78
|
+
}
|
|
68
79
|
};
|
|
69
80
|
|
|
70
81
|
const fixActivityLog = async (post, startTime) => {
|
|
@@ -197,14 +208,21 @@ module.exports.watchNewsletter = async (event, context, callback) => {
|
|
|
197
208
|
};
|
|
198
209
|
console.log("running query");
|
|
199
210
|
console.log(query);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
211
|
+
|
|
212
|
+
// Wait for query to complete
|
|
213
|
+
const res = await indexQuery(values.tableNameNewsletterEntries, query);
|
|
214
|
+
|
|
215
|
+
console.log(`Found ${res.Items.length} newsletters to send notifications for`);
|
|
216
|
+
|
|
217
|
+
// Process newsletters sequentially to ensure each completes before next starts
|
|
218
|
+
for (const update of res.Items) {
|
|
219
|
+
console.log(
|
|
220
|
+
`sending notifications for ${update.RowId} - ${update.Title}`
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// Wait for each newsletter's notifications to complete
|
|
224
|
+
await sendNotifications(update);
|
|
225
|
+
}
|
|
208
226
|
|
|
209
227
|
await checkFixLog(startTime);
|
|
210
228
|
};
|