Formatting.
This commit is contained in:
parent
85441c6141
commit
163035cac7
|
@ -1,12 +1,6 @@
|
||||||
const {
|
const { generateTemplateID, StaticDatabases } = require("@budibase/auth").db
|
||||||
generateTemplateID,
|
|
||||||
StaticDatabases,
|
|
||||||
} = require("@budibase/auth").db
|
|
||||||
const { CouchDB } = require("../../../db")
|
const { CouchDB } = require("../../../db")
|
||||||
const {
|
const { TemplateMetadata, TemplateBindings } = require("../../../constants")
|
||||||
TemplateMetadata,
|
|
||||||
TemplateBindings,
|
|
||||||
} = require("../../../constants")
|
|
||||||
const { getTemplates } = require("../../../constants/templates")
|
const { getTemplates } = require("../../../constants/templates")
|
||||||
|
|
||||||
const GLOBAL_DB = StaticDatabases.GLOBAL.name
|
const GLOBAL_DB = StaticDatabases.GLOBAL.name
|
||||||
|
|
|
@ -46,12 +46,12 @@ const TemplateMetadata = {
|
||||||
{
|
{
|
||||||
name: "Styling",
|
name: "Styling",
|
||||||
purpose: EmailTemplatePurpose.STYLES,
|
purpose: EmailTemplatePurpose.STYLES,
|
||||||
bindings: ["url", "company", "companyUrl", "styles", "body"]
|
bindings: ["url", "company", "companyUrl", "styles", "body"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Base Format",
|
name: "Base Format",
|
||||||
purpose: EmailTemplatePurpose.BASE,
|
purpose: EmailTemplatePurpose.BASE,
|
||||||
bindings: ["company", "registrationUrl"]
|
bindings: ["company", "registrationUrl"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Password Recovery",
|
name: "Password Recovery",
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
const { readStaticFile } = require("../../utilities/fileSystem")
|
const { readStaticFile } = require("../../utilities/fileSystem")
|
||||||
const { EmailTemplatePurpose, TemplateTypes, TemplatePurpose } = require("../index")
|
const {
|
||||||
|
EmailTemplatePurpose,
|
||||||
|
TemplateTypes,
|
||||||
|
TemplatePurpose,
|
||||||
|
} = require("../index")
|
||||||
const { join } = require("path")
|
const { join } = require("path")
|
||||||
const CouchDB = require("../../db")
|
const CouchDB = require("../../db")
|
||||||
const {
|
const { getTemplateParams, StaticDatabases } = require("@budibase/auth").db
|
||||||
getTemplateParams,
|
|
||||||
StaticDatabases,
|
|
||||||
} = require("@budibase/auth").db
|
|
||||||
|
|
||||||
const TEMPLATE_PATH = join(__dirname, "..", "constants", "templates")
|
const TEMPLATE_PATH = join(__dirname, "..", "constants", "templates")
|
||||||
|
|
||||||
|
@ -16,9 +17,7 @@ exports.EmailTemplates = {
|
||||||
[EmailTemplatePurpose.INVITATION]: readStaticFile(
|
[EmailTemplatePurpose.INVITATION]: readStaticFile(
|
||||||
join(TEMPLATE_PATH, "invitation.html")
|
join(TEMPLATE_PATH, "invitation.html")
|
||||||
),
|
),
|
||||||
[EmailTemplatePurpose.BASE]: readStaticFile(
|
[EmailTemplatePurpose.BASE]: readStaticFile(join(TEMPLATE_PATH, "base.html")),
|
||||||
join(TEMPLATE_PATH, "base.html")
|
|
||||||
),
|
|
||||||
[EmailTemplatePurpose.STYLES]: readStaticFile(
|
[EmailTemplatePurpose.STYLES]: readStaticFile(
|
||||||
join(TEMPLATE_PATH, "style.css")
|
join(TEMPLATE_PATH, "style.css")
|
||||||
),
|
),
|
||||||
|
@ -68,4 +67,3 @@ exports.getTemplateByPurpose = async (type, purpose) => {
|
||||||
const templates = await exports.getTemplates({ type })
|
const templates = await exports.getTemplates({ type })
|
||||||
return templates.find(template => template.purpose === purpose)
|
return templates.find(template => template.purpose === purpose)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,10 @@ const { getSettingsTemplateContext } = require("./templates")
|
||||||
|
|
||||||
const TYPE = TemplateTypes.EMAIL
|
const TYPE = TemplateTypes.EMAIL
|
||||||
|
|
||||||
const FULL_EMAIL_PURPOSES = [EmailTemplatePurpose.INVITATION, EmailTemplatePurpose.PASSWORD_RECOVERY]
|
const FULL_EMAIL_PURPOSES = [
|
||||||
|
EmailTemplatePurpose.INVITATION,
|
||||||
|
EmailTemplatePurpose.PASSWORD_RECOVERY,
|
||||||
|
]
|
||||||
|
|
||||||
exports.buildEmail = async (email, user, purpose) => {
|
exports.buildEmail = async (email, user, purpose) => {
|
||||||
// this isn't a full email
|
// this isn't a full email
|
||||||
|
@ -20,9 +23,9 @@ exports.buildEmail = async (email, user, purpose) => {
|
||||||
|
|
||||||
// TODO: need to extend the context as much as possible
|
// TODO: need to extend the context as much as possible
|
||||||
const context = {
|
const context = {
|
||||||
...await getSettingsTemplateContext(),
|
...(await getSettingsTemplateContext()),
|
||||||
email,
|
email,
|
||||||
user
|
user,
|
||||||
}
|
}
|
||||||
|
|
||||||
body = await processString(body, context)
|
body = await processString(body, context)
|
||||||
|
@ -33,4 +36,4 @@ exports.buildEmail = async (email, user, purpose) => {
|
||||||
styles,
|
styles,
|
||||||
body,
|
body,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,10 @@ exports.getSettingsTemplateContext = async () => {
|
||||||
return {
|
return {
|
||||||
[TemplateBindings.LOGO_URL]: settings.logoUrl || LOGO_URL,
|
[TemplateBindings.LOGO_URL]: settings.logoUrl || LOGO_URL,
|
||||||
[TemplateBindings.URL]: settings.url,
|
[TemplateBindings.URL]: settings.url,
|
||||||
[TemplateBindings.REGISTRATION_URL]: checkSlashesInUrl(`${settings.url}/registration`),
|
[TemplateBindings.REGISTRATION_URL]: checkSlashesInUrl(
|
||||||
|
`${settings.url}/registration`
|
||||||
|
),
|
||||||
[TemplateBindings.RESET_URL]: checkSlashesInUrl(`${settings.url}/reset`),
|
[TemplateBindings.RESET_URL]: checkSlashesInUrl(`${settings.url}/reset`),
|
||||||
[TemplateBindings.COMPANY]: settings.company || BASE_COMPANY,
|
[TemplateBindings.COMPANY]: settings.company || BASE_COMPANY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue