2021-04-07 06:31:44 +03:00
|
|
|
const errors = require('@tryghost/errors');
|
2021-03-03 15:35:45 +03:00
|
|
|
const config = require('../../shared/config');
|
|
|
|
const db = require('../data/db');
|
|
|
|
const LimitService = require('@tryghost/limit-service');
|
|
|
|
let limitService = new LimitService();
|
|
|
|
|
2021-10-25 15:56:15 +03:00
|
|
|
const init = () => {
|
2021-03-03 15:35:45 +03:00
|
|
|
let helpLink;
|
|
|
|
|
2021-03-04 14:34:11 +03:00
|
|
|
if (config.get('hostSettings:billing:enabled') && config.get('hostSettings:billing:enabled') === true && config.get('hostSettings:billing:url')) {
|
|
|
|
helpLink = config.get('hostSettings:billing:url');
|
2021-03-03 15:35:45 +03:00
|
|
|
} else {
|
|
|
|
helpLink = 'https://ghost.org/help/';
|
|
|
|
}
|
|
|
|
|
2021-05-07 17:41:49 +03:00
|
|
|
let subscription;
|
|
|
|
|
|
|
|
if (config.get('hostSettings:subscription')) {
|
|
|
|
subscription = {
|
|
|
|
startDate: config.get('hostSettings:subscription:start'),
|
|
|
|
interval: 'month'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-23 19:46:52 +03:00
|
|
|
const hostLimits = config.get('hostSettings:limits') || {};
|
|
|
|
|
2021-05-07 17:41:49 +03:00
|
|
|
limitService.loadLimits({
|
2021-10-25 15:56:15 +03:00
|
|
|
limits: hostLimits,
|
2021-05-07 17:41:49 +03:00
|
|
|
subscription,
|
|
|
|
db,
|
|
|
|
helpLink,
|
|
|
|
errors
|
|
|
|
});
|
2021-03-03 15:35:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = limitService;
|
|
|
|
|
2021-10-25 15:56:15 +03:00
|
|
|
module.exports.init = init;
|