mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
00f6c76d1f
refs https://github.com/TryGhost/Team/issues/694 - This is a tiny step towards more decoupled scheduler's code organization - Similar to previous commit, it's just code extraction - Next steps will be injecting these modules as "init" function depencency" so we can test scheduling behavior in isolation
25 lines
759 B
JavaScript
25 lines
759 B
JavaScript
const models = require('../../../models');
|
|
const i18n = require('../../../../shared/i18n');
|
|
const errors = require('@tryghost/errors');
|
|
|
|
/**
|
|
* @description Load the internal scheduler integration
|
|
*
|
|
* @return {Promise}
|
|
*/
|
|
const getSchedulerIntegration = function () {
|
|
return models.Integration.findOne({slug: 'ghost-scheduler'}, {withRelated: 'api_keys'})
|
|
.then((integration) => {
|
|
if (!integration) {
|
|
throw new errors.NotFoundError({
|
|
message: i18n.t('errors.api.resource.resourceNotFound', {
|
|
resource: 'Integration'
|
|
})
|
|
});
|
|
}
|
|
return integration.toJSON();
|
|
});
|
|
};
|
|
|
|
module.exports = getSchedulerIntegration;
|