Ghost/core/server/adapters/scheduling/post-scheduling/scheduler-intergation.js
Naz 00f6c76d1f Extracted scheduling integration fetching into separate module
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
2021-05-24 17:34:36 +04:00

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;