@paroicms/contact-form-plugin
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -6,7 +6,7 @@ "use strict"; | ||
const public_server_lib_1 = require("@paroicms/public-server-lib"); | ||
async function sendContactFormMail(ctx, input, i18n) { | ||
async function sendContactFormMail(service, input, i18n) { | ||
const { email, name, message, subject, gRecaptchaResponse } = input; | ||
let contactEmail; | ||
try { | ||
contactEmail = (0, data_formatters_lib_1.strValOrUndef)(await ctx.getSiteFieldValue({ | ||
contactEmail = (0, data_formatters_lib_1.strValOrUndef)(await service.getSiteFieldValue({ | ||
fieldName: "contactEmail", | ||
@@ -16,4 +16,4 @@ language: input.language, | ||
if (!contactEmail) | ||
throw new Error(`['${ctx.fqdn}'] missing 'contactEmail'`); | ||
if (!(await ctx.validateRecaptchaResponse(gRecaptchaResponse))) { | ||
throw new Error(`['${service.fqdn}'] missing 'contactEmail'`); | ||
if (!(await service.validateRecaptchaResponse(gRecaptchaResponse))) { | ||
throw new Error("invalid recaptcha response"); | ||
@@ -28,5 +28,5 @@ } | ||
language: input.language, | ||
args: [ctx.fqdn], | ||
args: [service.fqdn], | ||
}); | ||
await ctx.sendMail({ | ||
await service.sendMail({ | ||
to: contactEmail, | ||
@@ -46,3 +46,3 @@ replyTo: { email, name }, | ||
<p>${(0, public_server_lib_1.escapeHtml)(message, { newLinesToBr: true })}</p>`, | ||
}, { appLog: ctx.siteLog }); | ||
}); | ||
return { | ||
@@ -55,3 +55,3 @@ success: true, | ||
throw err; | ||
ctx.siteLog.error(`fail to send mail: ${(0, data_formatters_lib_1.messageOf)(err)}`); | ||
service.logger.error(`fail to send mail: ${(0, data_formatters_lib_1.messageOf)(err)}`); | ||
return { | ||
@@ -58,0 +58,0 @@ success: false, |
@@ -18,7 +18,7 @@ "use strict"; | ||
languages: ["en", "fr"], | ||
appLog: service.siteLog, | ||
appLog: service.logger, | ||
}); | ||
service.setPublicAssetsDirectory((0, node_path_1.join)(packageDir, "public-front", "dist")); | ||
service.addHeadTag(`<link rel="stylesheet" href="${(0, public_server_lib_1.escapeHtml)(`${service.pluginAssetsUrl}/style.css`)}">`, `<script type="module" src="${(0, public_server_lib_1.escapeHtml)(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}"></script>`); | ||
service.setPublicApiHandler(async (ctx, req, res, relativePath) => { | ||
service.setPublicApiHandler(async (service, req, res, relativePath) => { | ||
if (relativePath !== "") { | ||
@@ -36,3 +36,3 @@ res.status(404).send({ status: 404 }); | ||
} | ||
const result = await (0, contact_form_mail_1.sendContactFormMail)(ctx, input, simpleI18n); | ||
const result = await (0, contact_form_mail_1.sendContactFormMail)(service, input, simpleI18n); | ||
res.send(result); | ||
@@ -39,0 +39,0 @@ }); |
{ | ||
"name": "@paroicms/contact-form-plugin", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Contact form plugin for ParoiCMS", | ||
@@ -33,4 +33,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@paroicms/public-anywhere-lib": "0.7.0", | ||
"@paroicms/public-server-lib": "0.13.0", | ||
"@paroicms/public-anywhere-lib": "0.8.0", | ||
"@paroicms/public-server-lib": "0.14.0", | ||
"@solid-primitives/i18n": "~2.1.1", | ||
@@ -37,0 +37,0 @@ "@types/node": "~20.14.8", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26892
712