mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Bootstrapped media inlining trigger endpoint
refs https://github.com/TryGhost/Toolbox/issues/524 - Added an endpoint to Admin API under `POST /db/media/inline` that accepts `domains` as JSON payload triggering media inlining job
This commit is contained in:
parent
da78e235dd
commit
de87479fb9
@ -3,6 +3,7 @@ const moment = require('moment-timezone');
|
||||
const dbBackup = require('../../data/db/backup');
|
||||
const exporter = require('../../data/exporter');
|
||||
const importer = require('../../data/importer');
|
||||
const mediaInliner = require('../../services/media-inliner');
|
||||
const errors = require('@tryghost/errors');
|
||||
const models = require('../../models');
|
||||
const settingsCache = require('../../../shared/settings-cache');
|
||||
@ -93,6 +94,22 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
inlineMedia: {
|
||||
permissions: {
|
||||
method: 'importContent'
|
||||
},
|
||||
validation: {
|
||||
options: {
|
||||
include: {
|
||||
values: ['domains']
|
||||
}
|
||||
}
|
||||
},
|
||||
async query(frame) {
|
||||
return mediaInliner.api.startMediaInliner(frame.data.domains);
|
||||
}
|
||||
},
|
||||
|
||||
deleteAllContent: {
|
||||
headers: {
|
||||
cacheInvalidate: true
|
||||
|
1
ghost/core/core/server/services/media-inliner/index.js
Normal file
1
ghost/core/core/server/services/media-inliner/index.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./service');
|
@ -5,8 +5,8 @@ module.exports = {
|
||||
this.api = {
|
||||
// @NOTE: the inlining should become an offloaded job
|
||||
// startMediaInliner: mediaInliner.inlineMedia
|
||||
startMediaInliner: () => {
|
||||
debug('[Inliner] Starting media inlining job');
|
||||
startMediaInliner: (domains) => {
|
||||
debug('[Inliner] Starting media inlining job for domains: ', domains);
|
||||
return {
|
||||
status: 'success'
|
||||
};
|
||||
|
@ -205,6 +205,12 @@ module.exports = function apiRoutes() {
|
||||
http(api.db.backupContent)
|
||||
);
|
||||
|
||||
router.post('/db/media/inline',
|
||||
mw.authAdminApi,
|
||||
labs.enabledMiddleware('mediaInliner'),
|
||||
http(api.db.inlineMedia)
|
||||
);
|
||||
|
||||
// ## Slack
|
||||
router.post('/slack/test', mw.authAdminApi, http(api.slack.sendTest));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user