mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
d72ba77aba
refs https://github.com/TryGhost/Team/issues/588 - This is a new type of limit allowing to measure resource use (e.g. sent emails) per period (e.g. subscription, billing, cycle, etc) - To enable periodical limit add following values under `hostSettings.limits`: ``` "emails": { "maxPeriodic": 10, "error": "Your plan supports up to {{max}} emails. Please upgrade to reenable sending emails." } ``` and following under `hostSettings.subscription`: ``` "subscription": { "start": "2020-04-02T15:53:55.000Z", "interval": "month" } ``` - Above config would allow checking if 10 emails per month starting on the 2nd of every month has been reached untill now
37 lines
979 B
JavaScript
37 lines
979 B
JavaScript
const errors = require('@tryghost/errors');
|
|
const config = require('../../shared/config');
|
|
const db = require('../data/db');
|
|
const LimitService = require('@tryghost/limit-service');
|
|
let limitService = new LimitService();
|
|
|
|
const initFn = () => {
|
|
let helpLink;
|
|
|
|
if (config.get('hostSettings:billing:enabled') && config.get('hostSettings:billing:enabled') === true && config.get('hostSettings:billing:url')) {
|
|
helpLink = config.get('hostSettings:billing:url');
|
|
} else {
|
|
helpLink = 'https://ghost.org/help/';
|
|
}
|
|
|
|
let subscription;
|
|
|
|
if (config.get('hostSettings:subscription')) {
|
|
subscription = {
|
|
startDate: config.get('hostSettings:subscription:start'),
|
|
interval: 'month'
|
|
};
|
|
}
|
|
|
|
limitService.loadLimits({
|
|
limits: config.get('hostSettings:limits'),
|
|
subscription,
|
|
db,
|
|
helpLink,
|
|
errors
|
|
});
|
|
};
|
|
|
|
module.exports = limitService;
|
|
|
|
module.exports.init = initFn;
|