2022-08-25 10:25:36 +03:00
|
|
|
class StaffService {
|
2022-09-02 17:57:59 +03:00
|
|
|
constructor({logging, models, mailer, settingsCache, settingsHelpers, urlUtils}) {
|
2022-08-25 10:25:36 +03:00
|
|
|
this.logging = logging;
|
|
|
|
|
|
|
|
/** @private */
|
|
|
|
this.settingsCache = settingsCache;
|
2022-08-25 17:48:56 +03:00
|
|
|
this.models = models;
|
2022-08-25 10:25:36 +03:00
|
|
|
|
|
|
|
const Emails = require('./emails');
|
2022-08-25 17:48:56 +03:00
|
|
|
|
2022-08-25 10:25:36 +03:00
|
|
|
/** @private */
|
|
|
|
this.emails = new Emails({
|
|
|
|
logging,
|
|
|
|
models,
|
|
|
|
mailer,
|
2022-09-02 17:57:59 +03:00
|
|
|
settingsHelpers,
|
2022-08-25 10:25:36 +03:00
|
|
|
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;
|