@plusscommunities/pluss-core-aws 2.1.4-beta.0 → 2.2.2-beta.0

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,32 @@
1
+ const indexQuery = require("../common/indexQuery");
2
+ const deleteRef = require("../common/deleteRef");
3
+
4
+ module.exports = async (entityId, type, site) => {
5
+ console.log("deleteNotificationsByEntity", { entityId, type, site });
6
+ const query = {
7
+ IndexName: "NotificationsIdIndex",
8
+ KeyConditionExpression: "Id = :entityId",
9
+ ExpressionAttributeValues: {
10
+ ":entityId": entityId,
11
+ },
12
+ };
13
+
14
+ let toDelete = [];
15
+ const { Items } = await indexQuery("notifications", query);
16
+ console.log("deleteNotificationsByEntity", JSON.stringify(Items, null, 2));
17
+ if (type || site) {
18
+ toDelete = Items.filter(
19
+ (i) => (!type || i.Type === type) && (!site || i.Site === site)
20
+ );
21
+ } else {
22
+ toDelete = Items;
23
+ }
24
+
25
+ const promises = [];
26
+ toDelete.forEach((i) => {
27
+ promises.push(deleteRef("notifications", "RowId", i.RowId));
28
+ console.log("deleteNotificationsByEntity - deleted", i.RowId);
29
+ });
30
+
31
+ return Promise.all(promises);
32
+ };
@@ -3,126 +3,155 @@ const { getConfig } = require("../config");
3
3
 
4
4
  module.exports = (noti) => {
5
5
  const thisNoti = { ...noti };
6
- const type = noti.Type ?? "";
7
- console.log("prepNotification - core", { type });
8
- if (type.startsWith("MaintenanceJobStatusChanged")) {
9
- thisNoti.Text = `Your request is ${noti.Data.status}`;
10
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
11
- thisNoti.Icon = "wrench";
12
- } else if (type.startsWith("MaintenanceJobAssigned")) {
13
- thisNoti.Text = `You have been assigned a request`;
14
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
15
- thisNoti.Icon = "wrench";
16
- } else if (type.startsWith("MaintenanceJobUnassigned")) {
17
- thisNoti.Text = `A request you were assigned has been reassigned`;
18
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
19
- thisNoti.Icon = "wrench";
20
- } else if (type.startsWith("MaintenanceJobCommented")) {
21
- thisNoti.Text = noti.Data.comment;
22
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
23
- thisNoti.Icon = "wrench";
24
- } else if (type.startsWith("EntityCommented")) {
25
- thisNoti.Text = noti.Data.comment;
26
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
27
- thisNoti.Icon = "commenting";
28
- } else if (type.startsWith("EventRepChange")) {
29
- let eventChangeText = "";
30
- if (noti.Data.LocationChanged && noti.Data.TimeChanged) {
31
- eventChangeText = "time and location";
32
- } else if (noti.Data.LocationChanged) {
33
- eventChangeText = "location";
34
- } else if (noti.Data.TimeChanged) {
35
- eventChangeText = "time";
36
- }
37
- thisNoti.Text = `An event you are attending has changed ${eventChangeText}`;
38
- thisNoti.Subtext = noti.Data.Title;
39
- thisNoti.Icon = "calendar";
40
- } else if (type.startsWith("EventRepRemoved")) {
41
- thisNoti.Text = "An event you are attending has been cancelled";
42
- thisNoti.Subtext = noti.Data.Title;
43
- thisNoti.TimeText = noti.Data.Time;
44
- thisNoti.Icon = "calendar-times-o";
45
- } else if (type.startsWith("ApproveNewsSubmission")) {
46
- thisNoti.Text = "A story you submitted has been approved";
47
- thisNoti.Subtext = noti.Data.Title;
48
- thisNoti.Icon = "newspaper-o";
49
- } else if (type.startsWith("ApproveEventSubmission")) {
50
- thisNoti.Text = "An event you submitted has been approved";
51
- thisNoti.Subtext = noti.Data.Title;
52
- thisNoti.Icon = "calendar-check-o";
53
- } else if (type.startsWith("EventRegisterFromWaitlist")) {
54
- thisNoti.Text =
55
- "A spot has opened up on an event you were on the waitlist for";
56
- thisNoti.Subtext = noti.Data.Title;
57
- thisNoti.Icon = "calendar-plus-o";
58
- } else if (type.startsWith("NewsletterPublished")) {
59
- thisNoti.Text = `News: ${noti.Data.Title}`;
60
- thisNoti.Subtext =
61
- !_.isEmpty(noti.Data.Text) && noti.Data.Text.length > 100
62
- ? `${noti.Data.Text.substring(0, 100)}...`
63
- : noti.Data.Text;
64
- thisNoti.Icon = "newspaper-o";
65
- } else if (type.startsWith("FormLockoutFailure")) {
66
- thisNoti.Text =
67
- "Someone answered yes to a question on the kiosk and was denied access";
68
- thisNoti.Icon = "exclamation-triangle";
69
- } else if (type.startsWith("FormLockoutSuccess")) {
70
- thisNoti.Text =
71
- "Someone answered no to all questions on the kiosk and was granted access";
72
- thisNoti.Icon = "check";
73
- } else if (type.startsWith("InformationAdded")) {
74
- thisNoti.Text = `There is new important information available: ${noti.Data.title}`;
75
- thisNoti.Icon = "info";
76
- } else if (type.startsWith("InformationUpdated")) {
77
- thisNoti.Text = `Important information updated: ${noti.Data.title}`;
78
- thisNoti.Icon = "info";
79
- } else if (type.startsWith("PollAdded")) {
80
- thisNoti.Text = `There is a new survey available: ${noti.Data.Title}`;
81
- thisNoti.Icon = "pie-chart";
82
- } else if (type.startsWith("OfferAdded")) {
83
- thisNoti.Text = `There is a new offer available: ${noti.Data.Title}`;
84
- thisNoti.Icon = "shopping-bag";
85
- } else if (type.startsWith("ServiceAdded")) {
86
- thisNoti.Text = `There is a new service available: ${noti.Data.Title}`;
87
- thisNoti.Icon = "stethoscope";
88
- } else if (type.startsWith("EventAdded")) {
89
- thisNoti.Text = `There is a new event: ${noti.Data.Title}`;
90
- thisNoti.Icon = "calendar-plus-o";
91
- } else if (type.startsWith("FacilityAdded")) {
92
- thisNoti.Text = `There is a new ${getConfig().strings.FACILITY}: ${
93
- noti.Data.Title
94
- }`;
95
- thisNoti.Icon = "building";
96
- } else if (type.startsWith("MapAdded")) {
97
- thisNoti.Text = `There is a new map: ${noti.Data.title}`;
98
- thisNoti.Icon = "map-marker";
99
- } else if (type.startsWith("ImportantContactAdded")) {
100
- thisNoti.Text = `There is a new contact: ${noti.Data.title}`;
101
- thisNoti.Icon = "address-card-o";
102
- } else if (type.startsWith("PersonalDocumentAdded")) {
103
- thisNoti.Text = `There is a new document: ${noti.Data.Name}`;
104
- thisNoti.Icon = "file-o";
105
- } else if (type.startsWith("AppointmentAdded")) {
106
- thisNoti.Text = noti.Data.message;
107
- thisNoti.Icon = "calendar-plus-o";
108
- } else if (type.startsWith("AppointmentUpdated")) {
109
- thisNoti.Text = noti.Data.message;
110
- thisNoti.Icon = "calendar-check-o";
111
- } else if (type.startsWith("AppointmentCancelled")) {
112
- thisNoti.Text = noti.Data.message;
113
- thisNoti.Icon = "calendar-times-o";
114
- } else if (type.startsWith("AppointmentReminder")) {
115
- thisNoti.Text = noti.Data.message;
116
- thisNoti.Icon = "bell-o";
117
- } else if (type.startsWith("AppointmentFollowup")) {
118
- thisNoti.Text = noti.Data.message;
119
- thisNoti.Icon = "calendar-check-o";
120
- } else if (type.startsWith("ScheduledAction")) {
121
- thisNoti.Text = noti.Data.message;
122
- thisNoti.Icon = "bell-o";
123
- } else {
124
- thisNoti.Text = "You have received a notification";
125
- thisNoti.Icon = "bell-o";
6
+ switch (noti.Type) {
7
+ case "MaintenanceJobStatusChanged":
8
+ thisNoti.Text = `Your request is ${noti.Data.status}`;
9
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
10
+ thisNoti.Icon = "wrench";
11
+ break;
12
+ case "MaintenanceJobAssigned":
13
+ thisNoti.Text = `You have been assigned a request`;
14
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
15
+ thisNoti.Icon = "wrench";
16
+ break;
17
+ case "MaintenanceJobUnassigned":
18
+ thisNoti.Text = `A request you were assigned has been reassigned`;
19
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
20
+ thisNoti.Icon = "wrench";
21
+ break;
22
+ case "MaintenanceJobCommented":
23
+ thisNoti.Text = noti.Data.comment;
24
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
25
+ thisNoti.Icon = "wrench";
26
+ break;
27
+ case "EntityCommented":
28
+ thisNoti.Text = noti.Data.comment;
29
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
30
+ thisNoti.Icon = "commenting";
31
+ break;
32
+ case "EventRepChange":
33
+ let eventChangeText = "";
34
+ if (noti.Data.LocationChanged && noti.Data.TimeChanged) {
35
+ eventChangeText = "time and location";
36
+ } else if (noti.Data.LocationChanged) {
37
+ eventChangeText = "location";
38
+ } else if (noti.Data.TimeChanged) {
39
+ eventChangeText = "time";
40
+ }
41
+ thisNoti.Text = `An event you are attending has changed ${eventChangeText}`;
42
+ thisNoti.Subtext = noti.Data.Title;
43
+ thisNoti.Icon = "calendar";
44
+ break;
45
+ case "EventRepRemoved":
46
+ thisNoti.Text = "An event you are attending has been cancelled";
47
+ thisNoti.Subtext = noti.Data.Title;
48
+ thisNoti.TimeText = noti.Data.Time;
49
+ thisNoti.Icon = "calendar-times-o";
50
+ break;
51
+ case "ApproveNewsSubmission":
52
+ thisNoti.Text = "A story you submitted has been approved";
53
+ thisNoti.Subtext = noti.Data.Title;
54
+ thisNoti.Icon = "newspaper-o";
55
+ break;
56
+ case "ApproveEventSubmission":
57
+ thisNoti.Text = "An event you submitted has been approved";
58
+ thisNoti.Subtext = noti.Data.Title;
59
+ thisNoti.Icon = "calendar-check-o";
60
+ break;
61
+ case "EventRegisterFromWaitlist":
62
+ thisNoti.Text =
63
+ "A spot has opened up on an event you were on the waitlist for";
64
+ thisNoti.Subtext = noti.Data.Title;
65
+ thisNoti.Icon = "calendar-plus-o";
66
+ break;
67
+ case "NewsletterPublished":
68
+ thisNoti.Text = `News: ${noti.Data.Title}`;
69
+ thisNoti.Subtext =
70
+ !_.isEmpty(noti.Data.Text) && noti.Data.Text.length > 100
71
+ ? `${noti.Data.Text.substring(0, 100)}...`
72
+ : noti.Data.Text;
73
+ thisNoti.Icon = "newspaper-o";
74
+ break;
75
+ case "FormLockoutFailure":
76
+ thisNoti.Text =
77
+ "Someone answered yes to a question on the kiosk and was denied access";
78
+ thisNoti.Icon = "exclamation-triangle";
79
+ break;
80
+ case "FormLockoutSuccess":
81
+ thisNoti.Text =
82
+ "Someone answered no to all questions on the kiosk and was granted access";
83
+ thisNoti.Icon = "check";
84
+ break;
85
+ case "InformationAdded":
86
+ thisNoti.Text = `There is new important information available: ${noti.Data.title}`;
87
+ thisNoti.Icon = "info";
88
+ break;
89
+ case "InformationUpdated":
90
+ thisNoti.Text = `Important information updated: ${noti.Data.title}`;
91
+ thisNoti.Icon = "info";
92
+ break;
93
+ case "PollAdded":
94
+ thisNoti.Text = `There is a new survey available: ${noti.Data.Title}`;
95
+ thisNoti.Icon = "pie-chart";
96
+ break;
97
+ case "OfferAdded":
98
+ thisNoti.Text = `There is a new offer available: ${noti.Data.Title}`;
99
+ thisNoti.Icon = "shopping-bag";
100
+ break;
101
+ case "ServiceAdded":
102
+ thisNoti.Text = `There is a new service available: ${noti.Data.Title}`;
103
+ thisNoti.Icon = "stethoscope";
104
+ break;
105
+ case "EventAdded":
106
+ thisNoti.Text = `There is a new event: ${noti.Data.Title}`;
107
+ thisNoti.Icon = "calendar-plus-o";
108
+ break;
109
+ case "FacilityAdded":
110
+ thisNoti.Text = `There is a new ${getConfig().strings.FACILITY}: ${
111
+ noti.Data.Title
112
+ }`;
113
+ thisNoti.Icon = "building";
114
+ break;
115
+ case "MapAdded":
116
+ thisNoti.Text = `There is a new map: ${noti.Data.title}`;
117
+ thisNoti.Icon = "map-marker";
118
+ break;
119
+ case "ImportantContactAdded":
120
+ thisNoti.Text = `There is a new contact: ${noti.Data.title}`;
121
+ thisNoti.Icon = "address-card-o";
122
+ break;
123
+ case "PersonalDocumentAdded":
124
+ thisNoti.Text = `There is a new document: ${noti.Data.Name}`;
125
+ thisNoti.Icon = "file-o";
126
+ break;
127
+ case "AppointmentAdded":
128
+ thisNoti.Text = noti.Data.message;
129
+ thisNoti.Icon = "calendar-plus-o";
130
+ break;
131
+ case "AppointmentUpdated":
132
+ thisNoti.Text = noti.Data.message;
133
+ thisNoti.Icon = "calendar-check-o";
134
+ break;
135
+ case "AppointmentCancelled":
136
+ thisNoti.Text = noti.Data.message;
137
+ thisNoti.Icon = "calendar-times-o";
138
+ break;
139
+ case "AppointmentReminder":
140
+ thisNoti.Text = noti.Data.message;
141
+ thisNoti.Icon = "bell-o";
142
+ break;
143
+ case "AppointmentFollowup":
144
+ thisNoti.Text = noti.Data.message;
145
+ thisNoti.Icon = "calendar-check-o";
146
+ break;
147
+ case "ScheduledAction":
148
+ thisNoti.Text = noti.Data.message;
149
+ thisNoti.Icon = "bell-o";
150
+ break;
151
+ default:
152
+ thisNoti.Text = "You have received a notification";
153
+ thisNoti.Icon = "bell-o";
154
+ break;
126
155
  }
127
156
  return thisNoti;
128
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "2.1.4-beta.0",
3
+ "version": "2.2.2-beta.0",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",