mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Wired up mock Mentions Admin API (#16134)
refs https://github.com/TryGhost/Team/issues/2416 This doesn't even return a Mention in the correct format at the moment, but it's just to get an endpoint there, behind a flag and returning data so that we can start playing with the API and having it hooked up the the Admin. The next step will be fleshing this out further and defining the services and repository to back it, as well as updating the Admin so that we can fetch mentions to display in the UI
This commit is contained in:
parent
e55405691a
commit
a8a279d667
@ -292,6 +292,7 @@ async function initServices({config}) {
|
||||
const audienceFeedback = require('./server/services/audience-feedback');
|
||||
const emailSuppressionList = require('./server/services/email-suppression-list');
|
||||
const emailService = require('./server/services/email-service');
|
||||
const mentionsService = require('./server/services/mentions');
|
||||
|
||||
const urlUtils = require('./shared/url-utils');
|
||||
|
||||
@ -305,6 +306,7 @@ async function initServices({config}) {
|
||||
|
||||
await Promise.all([
|
||||
memberAttribution.init(),
|
||||
mentionsService.init(),
|
||||
staffService.init(),
|
||||
members.init(),
|
||||
tiers.init(),
|
||||
|
@ -57,6 +57,10 @@ module.exports = {
|
||||
return apiFramework.pipeline(require('./posts'), localUtils);
|
||||
},
|
||||
|
||||
get mentions() {
|
||||
return apiFramework.pipeline(require('./mentions'), localUtils);
|
||||
},
|
||||
|
||||
get invites() {
|
||||
return apiFramework.pipeline(require('./invites'), localUtils);
|
||||
},
|
||||
|
19
ghost/core/core/server/api/endpoints/mentions.js
Normal file
19
ghost/core/core/server/api/endpoints/mentions.js
Normal file
@ -0,0 +1,19 @@
|
||||
const mentions = require('../../services/mentions');
|
||||
|
||||
module.exports = {
|
||||
docName: 'mentions',
|
||||
browse: {
|
||||
options: [
|
||||
'filter',
|
||||
'fields',
|
||||
'limit',
|
||||
'order',
|
||||
'page',
|
||||
'debug'
|
||||
],
|
||||
permissions: false,
|
||||
query(frame) {
|
||||
return mentions.controller.browse(frame);
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,24 @@
|
||||
module.exports = class MentionController {
|
||||
async init() {}
|
||||
/**
|
||||
* @param {import('@tryghost/api-framework').Frame} frame
|
||||
* @returns {Promise<Page<Mention>>}
|
||||
*/
|
||||
async browse(/*frame*/) {
|
||||
return {
|
||||
data: [{
|
||||
thing: true
|
||||
}],
|
||||
meta: {
|
||||
pagination: {
|
||||
page: 1,
|
||||
limit: 'all',
|
||||
pages: 1,
|
||||
total: 1,
|
||||
next: null,
|
||||
prev: null
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
1
ghost/core/core/server/services/mentions/index.js
Normal file
1
ghost/core/core/server/services/mentions/index.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./service');
|
8
ghost/core/core/server/services/mentions/service.js
Normal file
8
ghost/core/core/server/services/mentions/service.js
Normal file
@ -0,0 +1,8 @@
|
||||
const MentionController = require('./MentionController');
|
||||
|
||||
module.exports = {
|
||||
controller: new MentionController(),
|
||||
async init() {
|
||||
this.controller.init();
|
||||
}
|
||||
};
|
@ -5,6 +5,7 @@ const apiMw = require('../../middleware');
|
||||
const mw = require('./middleware');
|
||||
|
||||
const shared = require('../../../shared');
|
||||
const labs = require('../../../../../shared/labs');
|
||||
|
||||
module.exports = function apiRoutes() {
|
||||
const router = express.Router('admin api');
|
||||
@ -31,6 +32,8 @@ module.exports = function apiRoutes() {
|
||||
router.put('/posts/:id', mw.authAdminApi, http(api.posts.edit));
|
||||
router.del('/posts/:id', mw.authAdminApi, http(api.posts.destroy));
|
||||
|
||||
router.get('/mentions', labs.enabledMiddleware('webmentions'), mw.authAdminApi, http(api.mentions.browse));
|
||||
|
||||
router.put('/comments/:id', mw.authAdminApi, http(api.comments.edit));
|
||||
|
||||
// ## Pages
|
||||
|
Loading…
Reference in New Issue
Block a user