mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
2e85ae98be
fixes https://github.com/TryGhost/Team/issues/1855 fixes https://github.com/TryGhost/Team/issues/1866 This commit moves all duplicate methods to get the support email address to a single location. Also methods to get the default email domain are moved. For the location, I initially wanted to put it at the settings service. But that service doesn't feel like the right place. Instead I created a new settings helpers service. This service takes the settingsCache, urlUtils and config and calculates some special 'calculated' settings based on those: - Support email methods - Stripe (active) keys / stripe connected (also removed some duplicate code that calculated the keys in a couple of places) - All the calculated settings are moved to the settings helpers I'm not 100% confident in whether this is the right place to put the helpers. Suggestions are welcome.
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
class StaffService {
|
|
constructor({logging, models, mailer, settingsCache, settingsHelpers, urlUtils}) {
|
|
this.logging = logging;
|
|
|
|
/** @private */
|
|
this.settingsCache = settingsCache;
|
|
this.models = models;
|
|
|
|
const Emails = require('./emails');
|
|
|
|
/** @private */
|
|
this.emails = new Emails({
|
|
logging,
|
|
models,
|
|
mailer,
|
|
settingsHelpers,
|
|
settingsCache,
|
|
urlUtils
|
|
});
|
|
}
|
|
|
|
async notifyFreeMemberSignup(member, options) {
|
|
try {
|
|
await this.emails.notifyFreeMemberSignup(member, options);
|
|
} catch (e) {
|
|
this.logging.error(`Failed to notify free member signup - ${member?.id}`);
|
|
}
|
|
}
|
|
|
|
async notifyPaidSubscriptionStart({member, offer, tier, subscription}, options) {
|
|
try {
|
|
await this.emails.notifyPaidSubscriptionStarted({member, offer, tier, subscription}, options);
|
|
} catch (e) {
|
|
this.logging.error(`Failed to notify paid member subscription start - ${member?.id}`);
|
|
}
|
|
}
|
|
|
|
async notifyPaidSubscriptionCancel({member, cancellationReason, tier, subscription}, options) {
|
|
try {
|
|
await this.emails.notifyPaidSubscriptionCanceled({member, cancellationReason, tier, subscription}, options);
|
|
} catch (e) {
|
|
this.logging.error(`Failed to notify paid member subscription cancel - ${member?.id}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = StaffService;
|