mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 09:53:32 +03:00
8c1a0b8d0c
- Apps are marked as removed in 3.0, never officially launched and have been deprecated for at least 2 years. - We've slowly removed bits that got in our way or were insecure over time meaning they mostly didn't work - This cleans up the remainder of the logic - The tables should be cleaned up in a future major
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const models = require('../../models');
|
|
const common = require('../../lib/common');
|
|
|
|
const allowedTypes = {
|
|
post: models.Post,
|
|
tag: models.Tag,
|
|
user: models.User
|
|
};
|
|
|
|
module.exports = {
|
|
docName: 'slugs',
|
|
generate: {
|
|
options: [
|
|
'include',
|
|
'type'
|
|
],
|
|
data: [
|
|
'name'
|
|
],
|
|
permissions: true,
|
|
validation: {
|
|
options: {
|
|
type: {
|
|
required: true,
|
|
values: Object.keys(allowedTypes)
|
|
}
|
|
},
|
|
data: {
|
|
name: {
|
|
required: true
|
|
}
|
|
}
|
|
},
|
|
query(frame) {
|
|
return models.Base.Model.generateSlug(allowedTypes[frame.options.type], frame.data.name, {status: 'all'})
|
|
.then((slug) => {
|
|
if (!slug) {
|
|
return Promise.reject(new common.errors.GhostError({
|
|
message: common.i18n.t('errors.api.slugs.couldNotGenerateSlug')
|
|
}));
|
|
}
|
|
return slug;
|
|
});
|
|
}
|
|
}
|
|
};
|