@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.
Files changed (90) hide show
  1. package/aws/getDefaultEmailAddress.js +21 -21
  2. package/aws/getEmailService.js +16 -16
  3. package/aws/getEmailServiceInfo.js +26 -26
  4. package/aws/sendEmail.js +31 -31
  5. package/config.js +1 -1
  6. package/db/activity/publishActivity.js +22 -22
  7. package/db/analytics/checkActivityExists.js +15 -15
  8. package/db/analytics/logAnalyticsActivity.js +69 -37
  9. package/db/analytics/scheduleOldAggregation.js +14 -14
  10. package/db/auth/getSiteSetting.js +12 -12
  11. package/db/auth/getSiteUserTypes.js +16 -16
  12. package/db/auth/getUserAuth.js +13 -13
  13. package/db/automatedactions/getActionBySiteTrigger.js +9 -9
  14. package/db/common/deleteRef.js +21 -21
  15. package/db/common/editRef.js +36 -36
  16. package/db/common/getRef.js +23 -23
  17. package/db/common/getTableCount.js +18 -18
  18. package/db/common/indexQuery.js +17 -17
  19. package/db/common/indexQueryRecursive.js +20 -20
  20. package/db/common/scanRef.js +18 -18
  21. package/db/common/scanRefRecursive.js +20 -20
  22. package/db/common/updateAttribute.js +27 -27
  23. package/db/common/updateRef.js +20 -20
  24. package/db/linkedUsers/getLinkedBy.js +21 -21
  25. package/db/linkedUsers/getLinkedTo.js +21 -21
  26. package/db/notifications/deleteNotificationsByEntity.js +21 -21
  27. package/db/notifications/getNotificationSetting.js +14 -14
  28. package/db/notifications/publishNotifications.js +39 -39
  29. package/db/scheduledActions/deleteActionQueue.js +1 -1
  30. package/db/scheduledActions/getActionQueueByEntityId.js +10 -10
  31. package/db/scheduledActions/getActionQueueByEntityKey.js +9 -9
  32. package/db/scheduledActions/getActionQueueById.js +9 -9
  33. package/db/scheduledActions/getActionQueueByTriggerAt.js +14 -14
  34. package/db/scheduledActions/updateActionQueue.js +29 -29
  35. package/db/strings/getString.js +20 -20
  36. package/db/strings/logUpdate.js +18 -18
  37. package/db/templates/getTemplateById.js +1 -1
  38. package/db/templates/getTemplatesList.js +10 -10
  39. package/db/templates/updateTemplate.js +9 -9
  40. package/db/users/getRole.js +1 -1
  41. package/db/users/getUser.js +9 -9
  42. package/db/users/getUserByEmail.js +17 -17
  43. package/helper/audience/filterByAudienceType.js +27 -27
  44. package/helper/audience/filterOnAudienceType.js +26 -26
  45. package/helper/audience/getAudience.js +187 -187
  46. package/helper/audience/getMatchingAudienceTypes.js +21 -21
  47. package/helper/audience/getMatchingAudienceTypesFromPreview.js +60 -60
  48. package/helper/audience/getMatchingTags.js +15 -15
  49. package/helper/audience/isValidAudience.js +20 -20
  50. package/helper/auth/checkTokenBlacklist.js +17 -17
  51. package/helper/auth/getApiKeyFromReq.js +2 -2
  52. package/helper/auth/getSessionUser.js +70 -85
  53. package/helper/auth/getSessionUserFromReq.js +2 -2
  54. package/helper/auth/getSessionUserFromReqAuthKey.js +11 -11
  55. package/helper/auth/validateApiKey.js +32 -32
  56. package/helper/auth/validateMasterAuth.js +174 -174
  57. package/helper/auth/validateSiteAccess.js +12 -12
  58. package/helper/auth/validateSiteSetting.js +7 -7
  59. package/helper/auth/validateUserLoggedIn.js +19 -19
  60. package/helper/createGuid.js +5 -5
  61. package/helper/generateJsonResponse.js +27 -27
  62. package/helper/getUserPreview.js +57 -57
  63. package/helper/getUserPreviewFromHeader.js +17 -17
  64. package/helper/getUserPreviewFromReq.js +17 -17
  65. package/helper/hqPublishing.js +337 -0
  66. package/helper/index.js +28 -28
  67. package/helper/notifySiteConfigs.js +132 -0
  68. package/helper/opengraph/getOpenGraph.js +12 -12
  69. package/helper/rates/checkRateLimit.js +38 -38
  70. package/helper/requestToSource.js +10 -10
  71. package/helper/sendEmail.js +120 -120
  72. package/helper/templates/replacePlaceHolders.js +29 -29
  73. package/helper/time/getLocalTimestamp.js +18 -18
  74. package/helper/time/getSiteTimezone.js +11 -11
  75. package/helper/triggerAutomatedAction.js +25 -25
  76. package/helper/userToUserPreview.js +23 -23
  77. package/helper/users/getUserTypesByPermission.js +24 -24
  78. package/helper/users/getUsersByPermission.js +20 -20
  79. package/notification/prepNotification.js +144 -144
  80. package/notification/sendNotifications.js +166 -166
  81. package/package.json +35 -40
  82. package/templates/supportTicketEmails.js +8 -8
  83. package/helper/auth/context/AuthenticationContext.js +0 -50
  84. package/helper/auth/context/AuthenticationStrategy.js +0 -20
  85. package/helper/auth/context/auth0/Strategy.js +0 -12
  86. package/helper/auth/context/auth0/functions/decodeAccessToken.js +0 -102
  87. package/helper/auth/context/auth0/functions/getSessionUser.js +0 -21
  88. package/helper/auth/context/boltonclarke/Strategy.js +0 -10
  89. package/helper/auth/context/cognito/Strategy.js +0 -12
  90. package/helper/auth/context/cognito/functions/getSessionUser.js +0 -76
@@ -3,15 +3,15 @@ const { getRowId } = require("../");
3
3
  const getRef = require("../../db/common/getRef");
4
4
 
5
5
  module.exports = async (site) => {
6
- if (site) {
7
- const timezone = await getRef(
8
- "strings",
9
- "RowId",
10
- getRowId(site, "timezone")
11
- );
12
- if (timezone && !_.isEmpty(timezone.Value)) {
13
- return timezone.Value;
14
- }
15
- }
16
- return "Australia/Brisbane";
6
+ if (site) {
7
+ const timezone = await getRef(
8
+ "strings",
9
+ "RowId",
10
+ getRowId(site, "timezone"),
11
+ );
12
+ if (timezone && !_.isEmpty(timezone.Value)) {
13
+ return timezone.Value;
14
+ }
15
+ }
16
+ return "Australia/Brisbane";
17
17
  };
@@ -2,33 +2,33 @@ const getActionBySiteTrigger = require("../db/automatedactions/getActionBySiteTr
2
2
  const sendEmail = require("./sendEmail");
3
3
 
4
4
  const isActionConditionMet = (action, args = {}) => {
5
- if (!action) return false;
6
- if (!action?.Condition) return true;
7
- return args[action.Condition.type] === action.Condition.value;
5
+ if (!action) return false;
6
+ if (!action?.Condition) return true;
7
+ return args[action.Condition.type] === action.Condition.value;
8
8
  };
9
9
 
10
10
  module.exports = async (site, trigger, args = {}) => {
11
- const actions = await getActionBySiteTrigger(site, trigger);
12
- for await (const action of actions) {
13
- if (!isActionConditionMet(action, args)) continue;
11
+ const actions = await getActionBySiteTrigger(site, trigger);
12
+ for await (const action of actions) {
13
+ if (!isActionConditionMet(action, args)) continue;
14
14
 
15
- switch (action.ActionType) {
16
- case "email":
17
- let subject = action.ActionData.Subject;
18
- let content = action.ActionData.Content;
19
- let email = action.ActionData.Email;
20
- Object.keys(args).forEach((key) => {
21
- subject = subject.replace(`__${key}__`, args[key]);
22
- content = content.replace(`__${key}__`, args[key]);
23
- email = email.replace(`__${key}__`, args[key]);
24
- });
25
- // console.log("triggerAutomatedAction - email", {
26
- // subject,
27
- // content,
28
- // email,
29
- // });
30
- await sendEmail(email, subject, content);
31
- break;
32
- }
33
- }
15
+ switch (action.ActionType) {
16
+ case "email":
17
+ let subject = action.ActionData.Subject;
18
+ let content = action.ActionData.Content;
19
+ let email = action.ActionData.Email;
20
+ Object.keys(args).forEach((key) => {
21
+ subject = subject.replace(`__${key}__`, args[key]);
22
+ content = content.replace(`__${key}__`, args[key]);
23
+ email = email.replace(`__${key}__`, args[key]);
24
+ });
25
+ // console.log("triggerAutomatedAction - email", {
26
+ // subject,
27
+ // content,
28
+ // email,
29
+ // });
30
+ await sendEmail(email, subject, content);
31
+ break;
32
+ }
33
+ }
34
34
  };
@@ -1,27 +1,27 @@
1
1
  module.exports = (user, includeType, includeSite) => {
2
- const result = {
3
- id: user.Id || user.userId || user.id,
4
- displayName: user.displayName,
5
- profilePic: user.profilePic || null,
6
- };
2
+ const result = {
3
+ id: user.Id || user.userId || user.id,
4
+ displayName: user.displayName,
5
+ profilePic: user.profilePic || null,
6
+ };
7
7
 
8
- if (includeType || includeSite) {
9
- result.Roles = user.Roles;
10
- if (!user.Roles) {
11
- result.Roles = [
12
- {
13
- type: user.type,
14
- site: user.site,
15
- },
16
- ];
17
- }
18
- }
8
+ if (includeType || includeSite) {
9
+ result.Roles = user.Roles;
10
+ if (!user.Roles) {
11
+ result.Roles = [
12
+ {
13
+ type: user.type,
14
+ site: user.site,
15
+ },
16
+ ];
17
+ }
18
+ }
19
19
 
20
- if (includeType) {
21
- result.type = user.type || null;
22
- }
23
- if (includeSite) {
24
- result.site = user.site || null;
25
- }
26
- return result;
20
+ if (includeType) {
21
+ result.type = user.type || null;
22
+ }
23
+ if (includeSite) {
24
+ result.site = user.site || null;
25
+ }
26
+ return result;
27
27
  };
@@ -9,28 +9,28 @@ const getSiteUserTypes = require("../../db/auth/getSiteUserTypes");
9
9
  * @returns {Object[]} - An array of filtered user types.
10
10
  */
11
11
  module.exports = async (site, permissions) => {
12
- const logId = log("getUserTypesByPermission", "Input", { site, permissions });
13
- const siteUserTypes = await getSiteUserTypes(site);
14
- log("getUserTypesByPermission", "siteUserTypes", siteUserTypes, logId);
15
- const filteredUserTypes = siteUserTypes.filter((userType) =>
16
- userType.permissions.some((permission) => permissions.includes(permission))
17
- );
18
- if (!filteredUserTypes.some((userType) => userType.typeName === "master")) {
19
- const masterRole = {
20
- Id: `${site}_master`,
21
- site,
22
- displayName: "Master",
23
- typeName: "master",
24
- Permissions: [],
25
- category: "staff",
26
- };
27
- filteredUserTypes.push(masterRole);
28
- }
29
- log(
30
- "getUserTypesByPermission",
31
- "filteredUserTypes",
32
- filteredUserTypes,
33
- logId
34
- );
35
- return filteredUserTypes;
12
+ const logId = log("getUserTypesByPermission", "Input", { site, permissions });
13
+ const siteUserTypes = await getSiteUserTypes(site);
14
+ log("getUserTypesByPermission", "siteUserTypes", siteUserTypes, logId);
15
+ const filteredUserTypes = siteUserTypes.filter((userType) =>
16
+ userType.permissions.some((permission) => permissions.includes(permission)),
17
+ );
18
+ if (!filteredUserTypes.some((userType) => userType.typeName === "master")) {
19
+ const masterRole = {
20
+ Id: `${site}_master`,
21
+ site,
22
+ displayName: "Master",
23
+ typeName: "master",
24
+ Permissions: [],
25
+ category: "staff",
26
+ };
27
+ filteredUserTypes.push(masterRole);
28
+ }
29
+ log(
30
+ "getUserTypesByPermission",
31
+ "filteredUserTypes",
32
+ filteredUserTypes,
33
+ logId,
34
+ );
35
+ return filteredUserTypes;
36
36
  };
@@ -10,25 +10,25 @@ const { log } = require("..");
10
10
  * @returns {Promise<Array<object>>} - A promise that resolves to an array of users matching the given permissions.
11
11
  */
12
12
  module.exports = async (site, permissions) => {
13
- const logId = log("getUsersByPermission", "Input", { site, permissions });
14
- const userTypes = await getUserTypesByPermission(site, permissions);
15
- log("getUsersByPermission", "userTypes", userTypes, logId);
16
- const audienceMatches = userTypes.map((ut) => {
17
- return {
18
- AudienceType: "UserType",
19
- AudienceTypeSelection: ut.typeName,
20
- };
21
- });
22
- log("getUsersByPermission", "audienceMatches", audienceMatches, logId);
23
- const audience = await getAudience(
24
- site,
25
- "Custom",
26
- audienceMatches,
27
- true,
28
- false,
29
- false
30
- );
31
- log("getUsersByPermission", "audienceLength", audience.length, logId);
13
+ const logId = log("getUsersByPermission", "Input", { site, permissions });
14
+ const userTypes = await getUserTypesByPermission(site, permissions);
15
+ log("getUsersByPermission", "userTypes", userTypes, logId);
16
+ const audienceMatches = userTypes.map((ut) => {
17
+ return {
18
+ AudienceType: "UserType",
19
+ AudienceTypeSelection: ut.typeName,
20
+ };
21
+ });
22
+ log("getUsersByPermission", "audienceMatches", audienceMatches, logId);
23
+ const audience = await getAudience(
24
+ site,
25
+ "Custom",
26
+ audienceMatches,
27
+ true,
28
+ false,
29
+ false,
30
+ );
31
+ log("getUsersByPermission", "audienceLength", audience.length, logId);
32
32
 
33
- return audience;
33
+ return audience;
34
34
  };
@@ -2,148 +2,148 @@ const _ = require("lodash");
2
2
  const { getConfig } = require("../config");
3
3
 
4
4
  module.exports = (noti) => {
5
- const thisNoti = { ...noti };
6
- const type = noti.Type ?? "";
7
- if (type.startsWith("MaintenanceJobStatusChanged")) {
8
- thisNoti.Text = `Your request is ${noti.Data.status}`;
9
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
10
- thisNoti.Icon = "wrench";
11
- if (type.indexOf("Forms") > -1) {
12
- thisNoti.Icon = "file-text-o";
13
- thisNoti.Text = `Your form is ${noti.Data.status}`;
14
- }
15
- } else if (type.startsWith("MaintenanceJobAssigned")) {
16
- thisNoti.Text = `You have been assigned a request`;
17
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
18
- thisNoti.Icon = "wrench";
19
- if (type.indexOf("Forms") > -1) {
20
- thisNoti.Icon = "file-text-o";
21
- thisNoti.Text = `You have been assigned a form`;
22
- }
23
- } else if (type.startsWith("MaintenanceJobUnassigned")) {
24
- thisNoti.Text = `A request you were assigned has been reassigned`;
25
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
26
- thisNoti.Icon = "wrench";
27
- if (type.indexOf("Forms") > -1) {
28
- thisNoti.Icon = "file-text-o";
29
- thisNoti.Text = `A form you were assigned has been reassigned`;
30
- }
31
- } else if (type.startsWith("MaintenanceJobCommented")) {
32
- thisNoti.Text = noti.Data.comment;
33
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
34
- thisNoti.Icon = "wrench";
35
- if (type.indexOf("Forms") > -1) {
36
- thisNoti.Icon = "file-text-o";
37
- }
38
- } else if (type.startsWith("EntityCommented")) {
39
- thisNoti.Text = noti.Data.comment;
40
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
41
- thisNoti.Icon = "commenting";
42
- } else if (type.startsWith("EventRepChange")) {
43
- let eventChangeText = "";
44
- if (noti.Data.LocationChanged && noti.Data.TimeChanged) {
45
- eventChangeText = "time and location";
46
- } else if (noti.Data.LocationChanged) {
47
- eventChangeText = "location";
48
- } else if (noti.Data.TimeChanged) {
49
- eventChangeText = "time";
50
- }
51
- thisNoti.Text = `An event you are attending has changed ${eventChangeText}`;
52
- thisNoti.Subtext = noti.Data.Title;
53
- thisNoti.Icon = "calendar";
54
- } else if (type.startsWith("EventRepRemoved")) {
55
- thisNoti.Text = "An event you are attending has been cancelled";
56
- thisNoti.Subtext = noti.Data.Title;
57
- thisNoti.TimeText = noti.Data.Time;
58
- thisNoti.Icon = "calendar-times-o";
59
- } else if (type.startsWith("ApproveNewsSubmission")) {
60
- thisNoti.Text = "A story you submitted has been approved";
61
- thisNoti.Subtext = noti.Data.Title;
62
- thisNoti.Icon = "newspaper-o";
63
- } else if (type.startsWith("ApproveEventSubmission")) {
64
- thisNoti.Text = "An event you submitted has been approved";
65
- thisNoti.Subtext = noti.Data.Title;
66
- thisNoti.Icon = "calendar-check-o";
67
- } else if (type.startsWith("EventRegisterFromWaitlist")) {
68
- thisNoti.Text =
69
- "A spot has opened up on an event you were on the waitlist for";
70
- thisNoti.Subtext = noti.Data.Title;
71
- thisNoti.Icon = "calendar-plus-o";
72
- } else if (type.startsWith("NewsletterPublished")) {
73
- thisNoti.Text = `News: ${noti.Data.Title}`;
74
- thisNoti.Subtext =
75
- !_.isEmpty(noti.Data.Text) && noti.Data.Text.length > 100
76
- ? `${noti.Data.Text.substring(0, 100)}...`
77
- : noti.Data.Text;
78
- thisNoti.Icon = "newspaper-o";
79
- } else if (type.startsWith("FormLockoutFailure")) {
80
- thisNoti.Text =
81
- "Someone answered yes to a question on the kiosk and was denied access";
82
- thisNoti.Icon = "exclamation-triangle";
83
- } else if (type.startsWith("FormLockoutSuccess")) {
84
- thisNoti.Text =
85
- "Someone answered no to all questions on the kiosk and was granted access";
86
- thisNoti.Icon = "check";
87
- } else if (type.startsWith("InformationAdded")) {
88
- thisNoti.Text = `There is new important information available: ${noti.Data.title}`;
89
- thisNoti.Icon = "info";
90
- } else if (type.startsWith("InformationUpdated")) {
91
- thisNoti.Text = `Important information updated: ${noti.Data.title}`;
92
- thisNoti.Icon = "info";
93
- } else if (type.startsWith("PollAdded")) {
94
- thisNoti.Text = `There is a new survey available: ${noti.Data.Title}`;
95
- thisNoti.Icon = "pie-chart";
96
- } else if (type.startsWith("OfferAdded")) {
97
- thisNoti.Text = `There is a new offer available: ${noti.Data.Title}`;
98
- thisNoti.Icon = "shopping-bag";
99
- } else if (type.startsWith("ServiceAdded")) {
100
- thisNoti.Text = `There is a new service available: ${noti.Data.Title}`;
101
- thisNoti.Icon = "stethoscope";
102
- } else if (type.startsWith("EventAdded")) {
103
- thisNoti.Text = `There is a new event: ${noti.Data.Title}`;
104
- thisNoti.Icon = "calendar-plus-o";
105
- } else if (type.startsWith("FacilityAdded")) {
106
- thisNoti.Text = `There is a new ${getConfig().strings.FACILITY}: ${
107
- noti.Data.Title
108
- }`;
109
- thisNoti.Icon = "building";
110
- } else if (type.startsWith("MapAdded")) {
111
- thisNoti.Text = `There is a new map: ${noti.Data.title}`;
112
- thisNoti.Icon = "map-marker";
113
- } else if (type.startsWith("ImportantContactAdded")) {
114
- thisNoti.Text = `There is a new contact: ${noti.Data.title}`;
115
- thisNoti.Icon = "address-card-o";
116
- } else if (type.startsWith("PersonalDocumentAdded")) {
117
- thisNoti.Text = `There is a new document: ${noti.Data.Name}`;
118
- thisNoti.Icon = "file-o";
119
- } else if (type.startsWith("AppointmentAdded")) {
120
- thisNoti.Text = noti.Data.message;
121
- thisNoti.Icon = "calendar-plus-o";
122
- } else if (type.startsWith("AppointmentUpdated")) {
123
- thisNoti.Text = noti.Data.message;
124
- thisNoti.Icon = "calendar-check-o";
125
- } else if (type.startsWith("AppointmentCancelled")) {
126
- thisNoti.Text = noti.Data.message;
127
- thisNoti.Icon = "calendar-times-o";
128
- } else if (type.startsWith("AppointmentReminder")) {
129
- thisNoti.Text = noti.Data.message;
130
- thisNoti.Icon = "bell-o";
131
- } else if (type.startsWith("AppointmentFollowup")) {
132
- thisNoti.Text = noti.Data.message;
133
- thisNoti.Icon = "calendar-check-o";
134
- } else if (type.startsWith("ScheduledAction")) {
135
- thisNoti.Text = noti.Data.message;
136
- thisNoti.Icon = "bell-o";
137
- } else if (type.startsWith("FeedPostApproved")) {
138
- thisNoti.Text = `You have a new post for ${noti.Data.user.displayName}`;
139
- thisNoti.Subtext = noti.Data.title;
140
- thisNoti.Icon = "bars";
141
- } else if (type.startsWith("FeedPostToday")) {
142
- thisNoti.Text = `Review today's posts for ${noti.Data.displayName}`;
143
- thisNoti.Icon = "bars";
144
- } else {
145
- thisNoti.Text = "You have received a notification";
146
- thisNoti.Icon = "bell-o";
147
- }
148
- return thisNoti;
5
+ const thisNoti = { ...noti };
6
+ const type = noti.Type ?? "";
7
+ if (type.startsWith("MaintenanceJobStatusChanged")) {
8
+ thisNoti.Text = `Your request is ${noti.Data.status}`;
9
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
10
+ thisNoti.Icon = "wrench";
11
+ if (type.indexOf("Forms") > -1) {
12
+ thisNoti.Icon = "file-text-o";
13
+ thisNoti.Text = `Your form is ${noti.Data.status}`;
14
+ }
15
+ } else if (type.startsWith("MaintenanceJobAssigned")) {
16
+ thisNoti.Text = `You have been assigned a request`;
17
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
18
+ thisNoti.Icon = "wrench";
19
+ if (type.indexOf("Forms") > -1) {
20
+ thisNoti.Icon = "file-text-o";
21
+ thisNoti.Text = `You have been assigned a form`;
22
+ }
23
+ } else if (type.startsWith("MaintenanceJobUnassigned")) {
24
+ thisNoti.Text = `A request you were assigned has been reassigned`;
25
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
26
+ thisNoti.Icon = "wrench";
27
+ if (type.indexOf("Forms") > -1) {
28
+ thisNoti.Icon = "file-text-o";
29
+ thisNoti.Text = `A form you were assigned has been reassigned`;
30
+ }
31
+ } else if (type.startsWith("MaintenanceJobCommented")) {
32
+ thisNoti.Text = noti.Data.comment;
33
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
34
+ thisNoti.Icon = "wrench";
35
+ if (type.indexOf("Forms") > -1) {
36
+ thisNoti.Icon = "file-text-o";
37
+ }
38
+ } else if (type.startsWith("EntityCommented")) {
39
+ thisNoti.Text = noti.Data.comment;
40
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
41
+ thisNoti.Icon = "commenting";
42
+ } else if (type.startsWith("EventRepChange")) {
43
+ let eventChangeText = "";
44
+ if (noti.Data.LocationChanged && noti.Data.TimeChanged) {
45
+ eventChangeText = "time and location";
46
+ } else if (noti.Data.LocationChanged) {
47
+ eventChangeText = "location";
48
+ } else if (noti.Data.TimeChanged) {
49
+ eventChangeText = "time";
50
+ }
51
+ thisNoti.Text = `An event you are attending has changed ${eventChangeText}`;
52
+ thisNoti.Subtext = noti.Data.Title;
53
+ thisNoti.Icon = "calendar";
54
+ } else if (type.startsWith("EventRepRemoved")) {
55
+ thisNoti.Text = "An event you are attending has been cancelled";
56
+ thisNoti.Subtext = noti.Data.Title;
57
+ thisNoti.TimeText = noti.Data.Time;
58
+ thisNoti.Icon = "calendar-times-o";
59
+ } else if (type.startsWith("ApproveNewsSubmission")) {
60
+ thisNoti.Text = "A story you submitted has been approved";
61
+ thisNoti.Subtext = noti.Data.Title;
62
+ thisNoti.Icon = "newspaper-o";
63
+ } else if (type.startsWith("ApproveEventSubmission")) {
64
+ thisNoti.Text = "An event you submitted has been approved";
65
+ thisNoti.Subtext = noti.Data.Title;
66
+ thisNoti.Icon = "calendar-check-o";
67
+ } else if (type.startsWith("EventRegisterFromWaitlist")) {
68
+ thisNoti.Text =
69
+ "A spot has opened up on an event you were on the waitlist for";
70
+ thisNoti.Subtext = noti.Data.Title;
71
+ thisNoti.Icon = "calendar-plus-o";
72
+ } else if (type.startsWith("NewsletterPublished")) {
73
+ thisNoti.Text = `News: ${noti.Data.Title}`;
74
+ thisNoti.Subtext =
75
+ !_.isEmpty(noti.Data.Text) && noti.Data.Text.length > 100
76
+ ? `${noti.Data.Text.substring(0, 100)}...`
77
+ : noti.Data.Text;
78
+ thisNoti.Icon = "newspaper-o";
79
+ } else if (type.startsWith("FormLockoutFailure")) {
80
+ thisNoti.Text =
81
+ "Someone answered yes to a question on the kiosk and was denied access";
82
+ thisNoti.Icon = "exclamation-triangle";
83
+ } else if (type.startsWith("FormLockoutSuccess")) {
84
+ thisNoti.Text =
85
+ "Someone answered no to all questions on the kiosk and was granted access";
86
+ thisNoti.Icon = "check";
87
+ } else if (type.startsWith("InformationAdded")) {
88
+ thisNoti.Text = `There is new important information available: ${noti.Data.title}`;
89
+ thisNoti.Icon = "info";
90
+ } else if (type.startsWith("InformationUpdated")) {
91
+ thisNoti.Text = `Important information updated: ${noti.Data.title}`;
92
+ thisNoti.Icon = "info";
93
+ } else if (type.startsWith("PollAdded")) {
94
+ thisNoti.Text = `There is a new survey available: ${noti.Data.Title}`;
95
+ thisNoti.Icon = "pie-chart";
96
+ } else if (type.startsWith("OfferAdded")) {
97
+ thisNoti.Text = `There is a new offer available: ${noti.Data.Title}`;
98
+ thisNoti.Icon = "shopping-bag";
99
+ } else if (type.startsWith("ServiceAdded")) {
100
+ thisNoti.Text = `There is a new service available: ${noti.Data.Title}`;
101
+ thisNoti.Icon = "stethoscope";
102
+ } else if (type.startsWith("EventAdded")) {
103
+ thisNoti.Text = `There is a new event: ${noti.Data.Title}`;
104
+ thisNoti.Icon = "calendar-plus-o";
105
+ } else if (type.startsWith("FacilityAdded")) {
106
+ thisNoti.Text = `There is a new ${getConfig().strings.FACILITY}: ${
107
+ noti.Data.Title
108
+ }`;
109
+ thisNoti.Icon = "building";
110
+ } else if (type.startsWith("MapAdded")) {
111
+ thisNoti.Text = `There is a new map: ${noti.Data.title}`;
112
+ thisNoti.Icon = "map-marker";
113
+ } else if (type.startsWith("ImportantContactAdded")) {
114
+ thisNoti.Text = `There is a new contact: ${noti.Data.title}`;
115
+ thisNoti.Icon = "address-card-o";
116
+ } else if (type.startsWith("PersonalDocumentAdded")) {
117
+ thisNoti.Text = `There is a new document: ${noti.Data.Name}`;
118
+ thisNoti.Icon = "file-o";
119
+ } else if (type.startsWith("AppointmentAdded")) {
120
+ thisNoti.Text = noti.Data.message;
121
+ thisNoti.Icon = "calendar-plus-o";
122
+ } else if (type.startsWith("AppointmentUpdated")) {
123
+ thisNoti.Text = noti.Data.message;
124
+ thisNoti.Icon = "calendar-check-o";
125
+ } else if (type.startsWith("AppointmentCancelled")) {
126
+ thisNoti.Text = noti.Data.message;
127
+ thisNoti.Icon = "calendar-times-o";
128
+ } else if (type.startsWith("AppointmentReminder")) {
129
+ thisNoti.Text = noti.Data.message;
130
+ thisNoti.Icon = "bell-o";
131
+ } else if (type.startsWith("AppointmentFollowup")) {
132
+ thisNoti.Text = noti.Data.message;
133
+ thisNoti.Icon = "calendar-check-o";
134
+ } else if (type.startsWith("ScheduledAction")) {
135
+ thisNoti.Text = noti.Data.message;
136
+ thisNoti.Icon = "bell-o";
137
+ } else if (type.startsWith("FeedPostApproved")) {
138
+ thisNoti.Text = `You have a new post for ${noti.Data.user.displayName}`;
139
+ thisNoti.Subtext = noti.Data.title;
140
+ thisNoti.Icon = "bars";
141
+ } else if (type.startsWith("FeedPostToday")) {
142
+ thisNoti.Text = `Review today's posts for ${noti.Data.displayName}`;
143
+ thisNoti.Icon = "bars";
144
+ } else {
145
+ thisNoti.Text = "You have received a notification";
146
+ thisNoti.Icon = "bell-o";
147
+ }
148
+ return thisNoti;
149
149
  };