@plusscommunities/pluss-newsletter-aws-projects 2.0.6-auth.0 → 2.0.6

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,3 @@
1
+ const deleteNotificationsByEntity = require("@plusscommunities/pluss-core-aws/db/notifications/deleteNotificationsByEntity");
2
+
3
+ module.exports = deleteNotificationsByEntity;
@@ -83,11 +83,13 @@ module.exports.getRecentNewsletterEntries = (event, context, callback) => {
83
83
  return !entry.Private && (!tvMode || entry.TVMode);
84
84
  });
85
85
  // if (!canManage) {
86
- filteredResult = await filterByAudienceType(
87
- filteredResult,
88
- event.headers.authkey,
89
- site
90
- );
86
+ if (event.headers.authkey) {
87
+ filteredResult = await filterByAudienceType(
88
+ filteredResult,
89
+ event.headers.authkey,
90
+ site
91
+ );
92
+ }
91
93
  // }
92
94
  const sortedResult = _.take(
93
95
  _.sortBy(filteredResult, "UnixTimestampReverse"),
@@ -7,6 +7,7 @@ const deleteRef = require("./common/db/common/deleteRef");
7
7
  const updateRef = require("./common/db/common/updateRef");
8
8
  const logUpdate = require("./common/db/strings/logUpdate");
9
9
  const publishNotifications = require("./common/db/notifications/publishNotifications");
10
+ const deleteNotificationsByEntity = require("./common/db/notifications/deleteNotificationsByEntity");
10
11
  const getAudience = require("./common/helper/audience/getAudience");
11
12
  const updateAttribute = require("./common/db/common/updateAttribute");
12
13
  const logAnalyticsActivity = require("@plusscommunities/pluss-core-aws/db/analytics/logAnalyticsActivity");
@@ -169,6 +170,7 @@ module.exports.newsletterChanged = (event, context, callback) => {
169
170
  });
170
171
 
171
172
  createUserEntries(data, tagged, toRemove);
173
+ if (data.Deleted) deleteNotificationsByEntity(data.RowId);
172
174
 
173
175
  site = data.Site;
174
176
  } else if (record.eventName == "REMOVE") {
@@ -185,6 +187,7 @@ module.exports.newsletterChanged = (event, context, callback) => {
185
187
  oldTags.push(previousData.SubmittedBy.id);
186
188
 
187
189
  createUserEntries(previousData, [], oldTags);
190
+ deleteNotificationsByEntity(previousData.RowId);
188
191
 
189
192
  site = previousData.Site;
190
193
  }