0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/services/mail/index.js
Naz 551bd5e511 Refactored email utils to a class with DI params
refs https://github.com/TryGhost/Toolbox/issues/292

- There's a need to reuse these utils in the version mismatch notification service. Having loads of tightly coupled dependencies makes it super hard to rip out this module for reuse
- It's a groundwork for extraction of the email-utils package
- Rewrote the unit tests that were written for these utils previously - they weren't testing anything useful. The goal of this util is to generate specific content based on provided data and available templates - now the tests do test those specific things, not the mailer itself!
2022-05-04 15:36:50 +08:00

15 lines
605 B
JavaScript

const path = require('path');
const urlUtils = require('../../../shared/url-utils');
const settingsCache = require('../../../shared/settings-cache');
const EmailContentGenerator = require('./EmailContentGenerator');
const emailContentGenerator = new EmailContentGenerator({
getSiteUrl: () => urlUtils.urlFor('home', true),
getSiteTitle: () => settingsCache.get('title'),
templatesDir: path.resolve(__dirname, '..', 'mail', 'templates')
});
exports.GhostMailer = require('./GhostMailer');
exports.utils = {
generateContent: emailContentGenerator.getContent.bind(emailContentGenerator)
};