mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +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 dbBackup = require('../../data/db/backup');
|
||||||
const exporter = require('../../data/exporter');
|
const exporter = require('../../data/exporter');
|
||||||
const importer = require('../../data/importer');
|
const importer = require('../../data/importer');
|
||||||
|
const mediaInliner = require('../../services/media-inliner');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
const settingsCache = require('../../../shared/settings-cache');
|
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: {
|
deleteAllContent: {
|
||||||
headers: {
|
headers: {
|
||||||
cacheInvalidate: true
|
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 = {
|
this.api = {
|
||||||
// @NOTE: the inlining should become an offloaded job
|
// @NOTE: the inlining should become an offloaded job
|
||||||
// startMediaInliner: mediaInliner.inlineMedia
|
// startMediaInliner: mediaInliner.inlineMedia
|
||||||
startMediaInliner: () => {
|
startMediaInliner: (domains) => {
|
||||||
debug('[Inliner] Starting media inlining job');
|
debug('[Inliner] Starting media inlining job for domains: ', domains);
|
||||||
return {
|
return {
|
||||||
status: 'success'
|
status: 'success'
|
||||||
};
|
};
|
||||||
|
@ -205,6 +205,12 @@ module.exports = function apiRoutes() {
|
|||||||
http(api.db.backupContent)
|
http(api.db.backupContent)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post('/db/media/inline',
|
||||||
|
mw.authAdminApi,
|
||||||
|
labs.enabledMiddleware('mediaInliner'),
|
||||||
|
http(api.db.inlineMedia)
|
||||||
|
);
|
||||||
|
|
||||||
// ## Slack
|
// ## Slack
|
||||||
router.post('/slack/test', mw.authAdminApi, http(api.slack.sendTest));
|
router.post('/slack/test', mw.authAdminApi, http(api.slack.sendTest));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user