Formatting.
This commit is contained in:
parent
85441c6141
commit
163035cac7
|
@ -1,12 +1,6 @@
|
|||
const {
|
||||
generateTemplateID,
|
||||
StaticDatabases,
|
||||
} = require("@budibase/auth").db
|
||||
const { generateTemplateID, StaticDatabases } = require("@budibase/auth").db
|
||||
const { CouchDB } = require("../../../db")
|
||||
const {
|
||||
TemplateMetadata,
|
||||
TemplateBindings,
|
||||
} = require("../../../constants")
|
||||
const { TemplateMetadata, TemplateBindings } = require("../../../constants")
|
||||
const { getTemplates } = require("../../../constants/templates")
|
||||
|
||||
const GLOBAL_DB = StaticDatabases.GLOBAL.name
|
||||
|
|
|
@ -46,12 +46,12 @@ const TemplateMetadata = {
|
|||
{
|
||||
name: "Styling",
|
||||
purpose: EmailTemplatePurpose.STYLES,
|
||||
bindings: ["url", "company", "companyUrl", "styles", "body"]
|
||||
bindings: ["url", "company", "companyUrl", "styles", "body"],
|
||||
},
|
||||
{
|
||||
name: "Base Format",
|
||||
purpose: EmailTemplatePurpose.BASE,
|
||||
bindings: ["company", "registrationUrl"]
|
||||
bindings: ["company", "registrationUrl"],
|
||||
},
|
||||
{
|
||||
name: "Password Recovery",
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
const { readStaticFile } = require("../../utilities/fileSystem")
|
||||
const { EmailTemplatePurpose, TemplateTypes, TemplatePurpose } = require("../index")
|
||||
const {
|
||||
EmailTemplatePurpose,
|
||||
TemplateTypes,
|
||||
TemplatePurpose,
|
||||
} = require("../index")
|
||||
const { join } = require("path")
|
||||
const CouchDB = require("../../db")
|
||||
const {
|
||||
getTemplateParams,
|
||||
StaticDatabases,
|
||||
} = require("@budibase/auth").db
|
||||
const { getTemplateParams, StaticDatabases } = require("@budibase/auth").db
|
||||
|
||||
const TEMPLATE_PATH = join(__dirname, "..", "constants", "templates")
|
||||
|
||||
|
@ -16,9 +17,7 @@ exports.EmailTemplates = {
|
|||
[EmailTemplatePurpose.INVITATION]: readStaticFile(
|
||||
join(TEMPLATE_PATH, "invitation.html")
|
||||
),
|
||||
[EmailTemplatePurpose.BASE]: readStaticFile(
|
||||
join(TEMPLATE_PATH, "base.html")
|
||||
),
|
||||
[EmailTemplatePurpose.BASE]: readStaticFile(join(TEMPLATE_PATH, "base.html")),
|
||||
[EmailTemplatePurpose.STYLES]: readStaticFile(
|
||||
join(TEMPLATE_PATH, "style.css")
|
||||
),
|
||||
|
@ -68,4 +67,3 @@ exports.getTemplateByPurpose = async (type, purpose) => {
|
|||
const templates = await exports.getTemplates({ type })
|
||||
return templates.find(template => template.purpose === purpose)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ const { getSettingsTemplateContext } = require("./templates")
|
|||
|
||||
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) => {
|
||||
// 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
|
||||
const context = {
|
||||
...await getSettingsTemplateContext(),
|
||||
...(await getSettingsTemplateContext()),
|
||||
email,
|
||||
user
|
||||
user,
|
||||
}
|
||||
|
||||
body = await processString(body, context)
|
||||
|
@ -33,4 +36,4 @@ exports.buildEmail = async (email, user, purpose) => {
|
|||
styles,
|
||||
body,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ exports.getSettingsTemplateContext = async () => {
|
|||
return {
|
||||
[TemplateBindings.LOGO_URL]: settings.logoUrl || LOGO_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.COMPANY]: settings.company || BASE_COMPANY,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue