From b55a95b9442d9044fdd73c0d7854993ddbb5911b Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Wed, 15 Feb 2023 12:10:29 +0200 Subject: [PATCH] Removed usage of `GhostMailer` in `MilestonesService` no issue - With the switch of using a `MilestoneCreatedEvent` we'll be decoupling the mailing functionality and not need `GhostMailer` as dependency in the package anymore --- .../server/services/milestones/service.js | 3 -- ghost/milestones/lib/MilestonesService.js | 18 -------- .../milestones/test/MilestonesService.test.js | 44 ------------------- 3 files changed, 65 deletions(-) diff --git a/ghost/core/core/server/services/milestones/service.js b/ghost/core/core/server/services/milestones/service.js index 4deb46bc62..d2051471b3 100644 --- a/ghost/core/core/server/services/milestones/service.js +++ b/ghost/core/core/server/services/milestones/service.js @@ -34,14 +34,11 @@ module.exports = { } = require('@tryghost/milestones'); const config = require('../../../shared/config'); const milestonesConfig = config.get('milestones'); - const {GhostMailer} = require('../mail'); - const mailer = new GhostMailer(); const repository = new InMemoryMilestoneRepository({DomainEvents}); const queries = new MilestoneQueries({db}); this.api = new MilestonesService({ - mailer, repository, milestonesConfig, // avoid using getters and pass as JSON queries diff --git a/ghost/milestones/lib/MilestonesService.js b/ghost/milestones/lib/MilestonesService.js index 0952a61932..25d110dc95 100644 --- a/ghost/milestones/lib/MilestonesService.js +++ b/ghost/milestones/lib/MilestonesService.js @@ -17,11 +17,6 @@ const Milestone = require('./Milestone'); * @prop {() => Promise} getDefaultCurrency */ -/** - * @typedef {object} ghostMailer - * @property {Function} send - */ - /** * @typedef {object} milestonesConfig * @prop {Array} milestonesConfig.arr @@ -34,10 +29,6 @@ module.exports = class MilestonesService { /** @type {IMilestoneRepository} */ #repository; - /** - * @type {ghostMailer} */ - #mailer; - /** * @type {milestonesConfig} */ #milestonesConfig; @@ -47,13 +38,11 @@ module.exports = class MilestonesService { /** * @param {object} deps - * @param {ghostMailer} deps.mailer * @param {IMilestoneRepository} deps.repository * @param {milestonesConfig} deps.milestonesConfig * @param {IQueries} deps.queries */ constructor(deps) { - this.#mailer = deps.mailer; this.#milestonesConfig = deps.milestonesConfig; this.#queries = deps.queries; this.#repository = deps.repository; @@ -147,13 +136,6 @@ module.exports = class MilestonesService { const shouldSendEmail = await this.#shouldSendEmail(); if (shouldSendEmail) { - // TODO: hook up Ghostmailer or use StaffService and trigger event to send email - // await this.#mailer.send({ - // subject: 'Test', - // html: '
Milestone achieved
', - // to: 'test@example.com' - // }); - milestone.emailSentAt = new Date(); } diff --git a/ghost/milestones/test/MilestonesService.test.js b/ghost/milestones/test/MilestonesService.test.js index eb6f142ad3..33ac10edfc 100644 --- a/ghost/milestones/test/MilestonesService.test.js +++ b/ghost/milestones/test/MilestonesService.test.js @@ -48,10 +48,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getARR() { @@ -108,10 +104,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getARR() { @@ -141,10 +133,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - // TODO: make this a stub - mailer: { - send: async () => {} - }, milestonesConfig, queries: { async getARR() { @@ -179,10 +167,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getARR() { @@ -207,10 +191,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getARR() { @@ -251,10 +231,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getARR() { @@ -284,10 +260,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getMembersCount() { @@ -341,10 +313,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getMembersCount() { @@ -382,10 +350,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getMembersCount() { @@ -419,10 +383,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getMembersCount() { @@ -462,10 +422,6 @@ describe('MilestonesService', function () { const milestoneEmailService = new MilestonesService({ repository, - mailer: { - // TODO: make this a stub - send: async () => {} - }, milestonesConfig, queries: { async getMembersCount() {