@plusscommunities/pluss-newsletter-aws-projects 1.3.5
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/addNewsletterEntry.js +155 -0
- package/common/db/activity/publishActivity.js +3 -0
- package/common/db/common/deleteRef.js +3 -0
- package/common/db/common/editRef.js +3 -0
- package/common/db/common/getRef.js +3 -0
- package/common/db/common/indexQuery.js +3 -0
- package/common/db/common/indexQueryRecursive.js +3 -0
- package/common/db/common/updateAttribute.js +3 -0
- package/common/db/common/updateRef.js +3 -0
- package/common/db/linkedUsers/getLinkedTo.js +3 -0
- package/common/db/notifications/publishNotifications.js +3 -0
- package/common/db/strings/logUpdate.js +3 -0
- package/common/db/users/getUser.js +3 -0
- package/common/helper/audience/filterByAudienceType.js +3 -0
- package/common/helper/audience/filterOnAudienceType.js +3 -0
- package/common/helper/audience/getAudience.js +3 -0
- package/common/helper/audience/getMatchingAudienceTypes.js +3 -0
- package/common/helper/auth/getSessionUser.js +3 -0
- package/common/helper/auth/validateMasterAuth.js +3 -0
- package/common/helper/auth/validateSiteAccess.js +3 -0
- package/common/helper/auth/validateUserLoggedIn.js +3 -0
- package/common/helper/generateJsonResponse.js +3 -0
- package/common/helper/getUserPreview.js +3 -0
- package/common/helper/getUserPreviewFromHeader.js +3 -0
- package/common/helper/index.js +9 -0
- package/common/helper/opengraph/getOpenGraph.js +30 -0
- package/common/helper/requestToSource.js +3 -0
- package/common/helper/sendEmail.js +3 -0
- package/common/templates/newsletterSubmissionEmail.js +14 -0
- package/config/index.js +8 -0
- package/config.json +1 -0
- package/deleteNewsletterEntry.js +75 -0
- package/editNewsletterEntry.js +93 -0
- package/editNewsletterSubmission.js +65 -0
- package/feature.config.awards.js +340 -0
- package/feature.config.coaching.js +341 -0
- package/feature.config.curatedposts.js +341 -0
- package/feature.config.default.js +341 -0
- package/feature.config.headoffice.js +341 -0
- package/feature.config.js +340 -0
- package/feature.config.menu.js +340 -0
- package/feature.config.noticeboard.js +341 -0
- package/feature.config.personaldev.js +341 -0
- package/feature.config.products.js +340 -0
- package/feature.config.projects.js +340 -0
- package/feature.config.sales.js +340 -0
- package/feature.config.sharing.js +341 -0
- package/feature.config.training.js +341 -0
- package/getAvailableNews.js +52 -0
- package/getFeaturedNewsletterEntries.js +93 -0
- package/getNews.js +77 -0
- package/getNewsletterEntries.js +123 -0
- package/getNewsletterEntry.js +36 -0
- package/getNewsletterSubmission.js +33 -0
- package/getNewsletterSubmissions.js +56 -0
- package/getPublishedAvailableNews.js +47 -0
- package/getPublishedEntries.js +68 -0
- package/getRecentNewsletterEntries.js +107 -0
- package/getSubmissionCount.js +44 -0
- package/getTaggedNews.js +116 -0
- package/handleNewsletterSubmission.js +100 -0
- package/hasNewsletterAccess.js +56 -0
- package/helper/checkUpdateSource.js +70 -0
- package/initConfig.js +4 -0
- package/newsletterChanged.js +182 -0
- package/package-lock.json +3093 -0
- package/package.json +48 -0
- package/searchAvailableNews.js +64 -0
- package/serverless.yml +453 -0
- package/watchNewsletter.js +84 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
const uuid = require("uuid");
|
|
2
|
+
const moment = require("moment");
|
|
3
|
+
const initConfig = require("./initConfig");
|
|
4
|
+
const { getRowId } = require("./common/helper");
|
|
5
|
+
const generateJsonResponse = require("./common/helper/generateJsonResponse");
|
|
6
|
+
const updateRef = require("./common/db/common/updateRef");
|
|
7
|
+
const getRef = require("./common/db/common/getRef");
|
|
8
|
+
const validateMasterAuth = require("./common/helper/auth/validateMasterAuth");
|
|
9
|
+
const getSessionUser = require("./common/helper/auth/getSessionUser");
|
|
10
|
+
const getUserPreview = require("./common/helper/getUserPreview");
|
|
11
|
+
const sendEmail = require("./common/helper/sendEmail");
|
|
12
|
+
const newsletterSubmissionEmail = require("./common/templates/newsletterSubmissionEmail");
|
|
13
|
+
const publishActivity = require("./common/db/activity/publishActivity");
|
|
14
|
+
const { values } = require("./feature.config");
|
|
15
|
+
|
|
16
|
+
const sendNewsSubmissionEmail = (update) => {
|
|
17
|
+
getRef(
|
|
18
|
+
"strings",
|
|
19
|
+
"RowId",
|
|
20
|
+
`${update.Site}_${values.stringPostfixSubmissionEmail}`
|
|
21
|
+
)
|
|
22
|
+
.then((ev) => {
|
|
23
|
+
sendEmail(
|
|
24
|
+
ev.Value,
|
|
25
|
+
newsletterSubmissionEmail.subject.replace("___TITLE___", update.Title),
|
|
26
|
+
newsletterSubmissionEmail.content
|
|
27
|
+
.replace("___TITLE___", update.Title)
|
|
28
|
+
.replace("___TEXT___", update.Text)
|
|
29
|
+
.replace("___NAME___", update.SubmittedBy.displayName)
|
|
30
|
+
.replace(/\n/g, " <br /> "),
|
|
31
|
+
true
|
|
32
|
+
);
|
|
33
|
+
})
|
|
34
|
+
.catch((err) => {
|
|
35
|
+
console.log("No email to send to");
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports.addNewsletterEntry = (event, context, callback) => {
|
|
40
|
+
initConfig();
|
|
41
|
+
const data = JSON.parse(event.body);
|
|
42
|
+
|
|
43
|
+
data.update.Id = uuid.v1();
|
|
44
|
+
|
|
45
|
+
if (!data.update.Timestamp && !data.update.UnixTimestamp) {
|
|
46
|
+
data.update.Timestamp = moment.utc().toISOString();
|
|
47
|
+
data.update.UnixTimestamp = moment.utc().valueOf();
|
|
48
|
+
}
|
|
49
|
+
data.update.UnixTimestampReverse =
|
|
50
|
+
Number.MAX_SAFE_INTEGER - data.update.UnixTimestamp;
|
|
51
|
+
data.update.RowId = getRowId(data.update.Site, data.update.Id);
|
|
52
|
+
if (data.update.IsFeatured && !data.update.IsFeaturedDate) {
|
|
53
|
+
data.update.IsFeaturedDate = moment.utc().unix();
|
|
54
|
+
} else if (!data.update.IsFeatured) {
|
|
55
|
+
data.update.IsFeaturedDate = null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (data.update.Notification) data.update.UnsentNotification = "X";
|
|
59
|
+
|
|
60
|
+
getSessionUser(event.headers.authkey).then((uid) => {
|
|
61
|
+
getUserPreview(uid).then((user) => {
|
|
62
|
+
data.update.SubmittedBy = user;
|
|
63
|
+
if (data.update.AuthorDisplay === "name") {
|
|
64
|
+
data.update.Author = user;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
validateMasterAuth(event, values.permissionNewsletter).then(
|
|
68
|
+
(authorised) => {
|
|
69
|
+
if (!authorised) {
|
|
70
|
+
validateMasterAuth(event, values.permissionNewsletterSubmit).then(
|
|
71
|
+
(authorised) => {
|
|
72
|
+
if (!authorised) {
|
|
73
|
+
console.error("Authorization not valid");
|
|
74
|
+
callback(
|
|
75
|
+
null,
|
|
76
|
+
generateJsonResponse(422, {
|
|
77
|
+
error: {
|
|
78
|
+
message: "Authorization not valid.",
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (data.update.Private) {
|
|
86
|
+
updateRef(values.tableNameNewsletterEntries, data.update)
|
|
87
|
+
.then((result) => {
|
|
88
|
+
callback(
|
|
89
|
+
null,
|
|
90
|
+
generateJsonResponse(200, {
|
|
91
|
+
success: true,
|
|
92
|
+
update: result,
|
|
93
|
+
reviewRequired: false,
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
})
|
|
97
|
+
.catch((error) => {
|
|
98
|
+
callback(null, generateJsonResponse(422, { error }));
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
updateRef(values.tableNameNewsletterSubmissions, data.update)
|
|
102
|
+
.then((result) => {
|
|
103
|
+
publishActivity(
|
|
104
|
+
values.activityAddNewsSubmission,
|
|
105
|
+
data.update.Site,
|
|
106
|
+
data.update.RowId,
|
|
107
|
+
user,
|
|
108
|
+
{ title: data.update.Title }
|
|
109
|
+
);
|
|
110
|
+
sendNewsSubmissionEmail(data.update);
|
|
111
|
+
callback(
|
|
112
|
+
null,
|
|
113
|
+
generateJsonResponse(200, {
|
|
114
|
+
success: true,
|
|
115
|
+
update: result,
|
|
116
|
+
reviewRequired: true,
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
})
|
|
120
|
+
.catch((error) => {
|
|
121
|
+
callback(null, generateJsonResponse(422, { error }));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
updateRef(values.tableNameNewsletterEntries, data.update)
|
|
128
|
+
.then((result) => {
|
|
129
|
+
if (!data.update.Private) {
|
|
130
|
+
publishActivity(
|
|
131
|
+
values.activityAddNews,
|
|
132
|
+
data.update.Site,
|
|
133
|
+
data.update.RowId,
|
|
134
|
+
user,
|
|
135
|
+
{ title: data.update.Title }
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
callback(
|
|
139
|
+
null,
|
|
140
|
+
generateJsonResponse(200, {
|
|
141
|
+
success: true,
|
|
142
|
+
update: result,
|
|
143
|
+
reviewRequired: false,
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
})
|
|
147
|
+
.catch((error) => {
|
|
148
|
+
callback(null, generateJsonResponse(422, { error }));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// const getOpenGraph = require("@plusscommunities/pluss-core-aws/helper/opengraph/getOpenGraph");
|
|
2
|
+
|
|
3
|
+
// module.exports = getOpenGraph;
|
|
4
|
+
|
|
5
|
+
const axios = require("axios");
|
|
6
|
+
|
|
7
|
+
module.exports = async (url) => {
|
|
8
|
+
return new Promise(async (resolve, reject) => {
|
|
9
|
+
const request = {
|
|
10
|
+
method: "GET",
|
|
11
|
+
url: "https://opengraph-io.p.rapidapi.com/api/1.1/sites",
|
|
12
|
+
params: {
|
|
13
|
+
url,
|
|
14
|
+
accept_lang: "en-US,en;q=0.9",
|
|
15
|
+
max_cache_age: "432000000",
|
|
16
|
+
},
|
|
17
|
+
headers: {
|
|
18
|
+
"x-rapidapi-host": "opengraph-io.p.rapidapi.com",
|
|
19
|
+
"x-rapidapi-key": "3941bc0a39msh60f09652e936b3dp1afe26jsn4163bac965cc",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const response = await axios(request);
|
|
25
|
+
return resolve(response.data);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return reject(e);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { values } = require("../../feature.config");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
subject: `${values.textNewNewsletterSubmission}: ___TITLE___`,
|
|
5
|
+
content: `<div style='margin-bottom: 40px; font-size: 14px; line-height: 23px; color: #3e4245;'>
|
|
6
|
+
___NAME___ ${values.textHasSubmittedANewNewsletterPost}
|
|
7
|
+
</div>
|
|
8
|
+
<div style='margin-bottom: 16px; font-size: 22px; line-height: 30px; color: #0a2246; font-weight: bold;'>
|
|
9
|
+
___TITLE___
|
|
10
|
+
</div>
|
|
11
|
+
<div style='margin-bottom: 40px; font-size: 14px; line-height: 23px; color: #3e4245;'>
|
|
12
|
+
___TEXT___
|
|
13
|
+
</div>`,
|
|
14
|
+
};
|
package/config/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const Config = require("../config.json");
|
|
2
|
+
|
|
3
|
+
module.exports.keys_url = Config.keys_url;
|
|
4
|
+
module.exports.MAINTENANCE_INSTANT_COMPLETE = Config.maintenanceInstantComplete;
|
|
5
|
+
module.exports.communityConfig = Config.communityConfig;
|
|
6
|
+
module.exports.ANY_SIGN_UP_SITE = Config.anySignUpSite;
|
|
7
|
+
module.exports.CONST_STRINGS = Config.strings;
|
|
8
|
+
module.exports.HAS_INTRO_TERMS = Config.hasIntroTerms;
|
package/config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"keys_url":"https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_cLZpGqJql/.well-known/jwks.json","maintenanceInstantComplete":false,"communityConfig":{"name":"Pluss Communities","company":"Pluss","subdomain":"pluss60","onelinkUrl":"http://onelink.to/pluss60","iosAppUrl":"https://itunes.apple.com/au/app/aveo/id1358888537?mt=8","androidAppUrl":"https://play.google.com/store/apps/details?id=pluss.android.aveo","emailBrandingAbovePoweredBy":{"image":"https://pluss60-dev-media.s3-ap-southeast-2.amazonaws.com/pluss/website/plusscommunites.png","height":29,"width":100},"adminSiteUrl":"https://dev.plusscommunities.com"},"anySignUpSite":"newstead","strings":{"FACILITY":"facility"},"hasIntroTerms":false}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const moment = require("moment");
|
|
2
|
+
const initConfig = require("./initConfig");
|
|
3
|
+
const generateJsonResponse = require("./common/helper/generateJsonResponse");
|
|
4
|
+
const editRef = require("./common/db/common/editRef");
|
|
5
|
+
const getRef = require("./common/db/common/getRef");
|
|
6
|
+
const validateMasterAuth = require("./common/helper/auth/validateMasterAuth");
|
|
7
|
+
const publishActivity = require("./common/db/activity/publishActivity");
|
|
8
|
+
const getUserPreviewFromHeader = require("./common/helper/getUserPreviewFromHeader");
|
|
9
|
+
const { values } = require("./feature.config");
|
|
10
|
+
|
|
11
|
+
module.exports.deleteNewsletterEntry = (event, context, callback) => {
|
|
12
|
+
initConfig();
|
|
13
|
+
const data = JSON.parse(event.body);
|
|
14
|
+
|
|
15
|
+
if (!data.site || !data.id) {
|
|
16
|
+
callback(
|
|
17
|
+
null,
|
|
18
|
+
generateJsonResponse(422, { error: "No site or id attached" })
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
validateMasterAuth(event, values.permissionNewsletter).then((authorised) => {
|
|
24
|
+
if (!authorised) {
|
|
25
|
+
console.error("Authorization not valid");
|
|
26
|
+
callback(
|
|
27
|
+
null,
|
|
28
|
+
generateJsonResponse(422, {
|
|
29
|
+
error: {
|
|
30
|
+
message: "Authorization not valid.",
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getRef(values.tableNameNewsletterEntries, "RowId", data.id).then(
|
|
38
|
+
(result) => {
|
|
39
|
+
if (result.Site !== data.site) {
|
|
40
|
+
return callback(
|
|
41
|
+
null,
|
|
42
|
+
generateJsonResponse(422, {
|
|
43
|
+
error: {
|
|
44
|
+
message: "Incorrect site.",
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
editRef(values.tableNameNewsletterEntries, "RowId", data.id, {
|
|
50
|
+
Deleted: true,
|
|
51
|
+
Changed: moment.utc().unix(),
|
|
52
|
+
})
|
|
53
|
+
.then(() => {
|
|
54
|
+
getUserPreviewFromHeader(event.headers.authkey).then((user) => {
|
|
55
|
+
publishActivity(
|
|
56
|
+
values.activityDeleteNews,
|
|
57
|
+
result.Site,
|
|
58
|
+
result.RowId,
|
|
59
|
+
user,
|
|
60
|
+
{
|
|
61
|
+
title: result.Title,
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
callback(null, generateJsonResponse(200, { success: true }));
|
|
66
|
+
return;
|
|
67
|
+
})
|
|
68
|
+
.catch((error) => {
|
|
69
|
+
callback(null, generateJsonResponse(422, { error }));
|
|
70
|
+
return;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const moment = require("moment");
|
|
2
|
+
const initConfig = require("./initConfig");
|
|
3
|
+
const generateJsonResponse = require("./common/helper/generateJsonResponse");
|
|
4
|
+
const editRef = require("./common/db/common/editRef");
|
|
5
|
+
const getRef = require("./common/db/common/getRef");
|
|
6
|
+
const validateMasterAuth = require("./common/helper/auth/validateMasterAuth");
|
|
7
|
+
const getUserPreviewFromHeader = require("./common/helper/getUserPreviewFromHeader");
|
|
8
|
+
const publishActivity = require("./common/db/activity/publishActivity");
|
|
9
|
+
const { values } = require("./feature.config");
|
|
10
|
+
|
|
11
|
+
module.exports.editNewsletterEntry = (event, context, callback) => {
|
|
12
|
+
initConfig();
|
|
13
|
+
const data = JSON.parse(event.body);
|
|
14
|
+
|
|
15
|
+
if (!data.update) {
|
|
16
|
+
callback(null, generateJsonResponse(422, { error: "No entry attached" }));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (data.update.UnixTimestamp) {
|
|
20
|
+
data.update.UnixTimestampReverse =
|
|
21
|
+
Number.MAX_SAFE_INTEGER - data.update.UnixTimestamp;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
validateMasterAuth(event, values.permissionNewsletter).then((authorised) => {
|
|
25
|
+
if (!authorised) {
|
|
26
|
+
console.error("Authorization not valid");
|
|
27
|
+
callback(
|
|
28
|
+
null,
|
|
29
|
+
generateJsonResponse(422, {
|
|
30
|
+
error: {
|
|
31
|
+
message: "Authorization not valid.",
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getRef(values.tableNameNewsletterEntries, "RowId", data.update.RowId).then(
|
|
39
|
+
(result) => {
|
|
40
|
+
if (result.Site !== data.site) {
|
|
41
|
+
return callback(
|
|
42
|
+
null,
|
|
43
|
+
generateJsonResponse(422, {
|
|
44
|
+
error: {
|
|
45
|
+
message: "Incorrect site.",
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
getUserPreviewFromHeader(event.headers.authkey)
|
|
51
|
+
.then((user) => {
|
|
52
|
+
if (
|
|
53
|
+
data.update.AuthorDisplay === "name" &&
|
|
54
|
+
result.AuthorDisplay !== "name"
|
|
55
|
+
) {
|
|
56
|
+
//list author if change was made
|
|
57
|
+
data.update.Author = user;
|
|
58
|
+
}
|
|
59
|
+
data.update.Changed = moment.utc().unix();
|
|
60
|
+
if (data.update.IsFeatured && !data.update.IsFeaturedDate) {
|
|
61
|
+
data.update.IsFeaturedDate = moment.utc().unix();
|
|
62
|
+
} else if (!data.update.IsFeatured) {
|
|
63
|
+
data.update.IsFeaturedDate = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
editRef(
|
|
67
|
+
values.tableNameNewsletterEntries,
|
|
68
|
+
"RowId",
|
|
69
|
+
data.update.RowId,
|
|
70
|
+
data.update
|
|
71
|
+
).then((result) => {
|
|
72
|
+
publishActivity(
|
|
73
|
+
values.activityEditNews,
|
|
74
|
+
data.update.Site,
|
|
75
|
+
data.update.RowId,
|
|
76
|
+
user,
|
|
77
|
+
{ title: data.update.Title }
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
callback(
|
|
81
|
+
null,
|
|
82
|
+
generateJsonResponse(200, { success: true, map: result })
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
})
|
|
86
|
+
.catch((error) => {
|
|
87
|
+
callback(null, generateJsonResponse(422, { error }));
|
|
88
|
+
return;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const initConfig = require("./initConfig");
|
|
2
|
+
const generateJsonResponse = require("./common/helper/generateJsonResponse");
|
|
3
|
+
const editRef = require("./common/db/common/editRef");
|
|
4
|
+
const getRef = require("./common/db/common/getRef");
|
|
5
|
+
const validateMasterAuth = require("./common/helper/auth/validateMasterAuth");
|
|
6
|
+
const { values } = require("./feature.config");
|
|
7
|
+
|
|
8
|
+
module.exports.editNewsletterSubmission = (event, context, callback) => {
|
|
9
|
+
initConfig();
|
|
10
|
+
const data = JSON.parse(event.body);
|
|
11
|
+
|
|
12
|
+
if (!data.update) {
|
|
13
|
+
callback(null, generateJsonResponse(422, { error: "No entry attached" }));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
validateMasterAuth(event, values.permissionNewsletter).then((authorised) => {
|
|
18
|
+
if (!authorised) {
|
|
19
|
+
console.error("Authorization not valid");
|
|
20
|
+
callback(
|
|
21
|
+
null,
|
|
22
|
+
generateJsonResponse(422, {
|
|
23
|
+
error: {
|
|
24
|
+
message: "Authorization not valid.",
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getRef(
|
|
32
|
+
values.tableNameNewsletterSubmissions,
|
|
33
|
+
"RowId",
|
|
34
|
+
data.update.RowId
|
|
35
|
+
).then((result) => {
|
|
36
|
+
if (result.Site !== data.site) {
|
|
37
|
+
return callback(
|
|
38
|
+
null,
|
|
39
|
+
generateJsonResponse(422, {
|
|
40
|
+
error: {
|
|
41
|
+
message: "Incorrect site.",
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
editRef(
|
|
47
|
+
values.tableNameNewsletterSubmissions,
|
|
48
|
+
"RowId",
|
|
49
|
+
data.update.RowId,
|
|
50
|
+
data.update
|
|
51
|
+
)
|
|
52
|
+
.then((result) => {
|
|
53
|
+
callback(
|
|
54
|
+
null,
|
|
55
|
+
generateJsonResponse(200, { success: true, map: result })
|
|
56
|
+
);
|
|
57
|
+
return;
|
|
58
|
+
})
|
|
59
|
+
.catch((error) => {
|
|
60
|
+
callback(null, generateJsonResponse(422, { error }));
|
|
61
|
+
return;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|