From 163035cac718eedc5467db28fda29fa1bfac76ba Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 22 Apr 2021 17:58:14 +0100 Subject: [PATCH] Formatting. --- .../src/api/controllers/admin/templates.js | 10 ++-------- packages/worker/src/constants/index.js | 4 ++-- packages/worker/src/constants/templates/index.js | 16 +++++++--------- packages/worker/src/utilities/email.js | 11 +++++++---- packages/worker/src/utilities/templates.js | 6 ++++-- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/packages/worker/src/api/controllers/admin/templates.js b/packages/worker/src/api/controllers/admin/templates.js index f01f8e2176..8d4065b77d 100644 --- a/packages/worker/src/api/controllers/admin/templates.js +++ b/packages/worker/src/api/controllers/admin/templates.js @@ -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 diff --git a/packages/worker/src/constants/index.js b/packages/worker/src/constants/index.js index bb002bbd6f..7406db0bdd 100644 --- a/packages/worker/src/constants/index.js +++ b/packages/worker/src/constants/index.js @@ -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", diff --git a/packages/worker/src/constants/templates/index.js b/packages/worker/src/constants/templates/index.js index 2878a3a4e9..16ec84a379 100644 --- a/packages/worker/src/constants/templates/index.js +++ b/packages/worker/src/constants/templates/index.js @@ -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) } - diff --git a/packages/worker/src/utilities/email.js b/packages/worker/src/utilities/email.js index 6cab9cc4db..83fb1ff8b6 100644 --- a/packages/worker/src/utilities/email.js +++ b/packages/worker/src/utilities/email.js @@ -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, }) -} \ No newline at end of file +} diff --git a/packages/worker/src/utilities/templates.js b/packages/worker/src/utilities/templates.js index 064776647d..9a3e2d291b 100644 --- a/packages/worker/src/utilities/templates.js +++ b/packages/worker/src/utilities/templates.js @@ -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, } -} \ No newline at end of file +}