Formatting.

This commit is contained in:
mike12345567 2021-04-22 17:58:14 +01:00
parent 737dd356c3
commit e2d29f0562
5 changed files with 22 additions and 25 deletions

View File

@ -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

View File

@ -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",

View File

@ -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)
}

View File

@ -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)

View File

@ -22,7 +22,9 @@ 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,
}