fixup validate
This commit is contained in:
@@ -23,23 +23,9 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
|
|||||||
return updatedParole
|
return updatedParole
|
||||||
},
|
},
|
||||||
async create(ctx) {
|
async create(ctx) {
|
||||||
const translateLyrics = async parolesFR => {
|
|
||||||
const anglais = await strapi.service('api::parole.parole').translate('FR', 'EN', parolesFR)
|
|
||||||
const espagnol = await strapi.service('api::parole.parole').translate('FR', 'ES', parolesFR)
|
|
||||||
const allemand = await strapi.service('api::parole.parole').translate('FR', 'DE', parolesFR)
|
|
||||||
const italien = await strapi.service('api::parole.parole').translate('FR', 'IT', parolesFR)
|
|
||||||
|
|
||||||
return {
|
|
||||||
francais: parolesFR,
|
|
||||||
anglais: anglais + '\n\n (Translated by DeepL)',
|
|
||||||
espagnol: espagnol + '\n\n (Traducido por DeepL)',
|
|
||||||
allemand: allemand + '\n\n (Übersetzt von DeepL)',
|
|
||||||
italien: italien + '\n\n (Tradotto da DeepL)'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const {body} = ctx.request
|
const {body} = ctx.request
|
||||||
const {data} = body
|
const {data} = body
|
||||||
|
strapi.service('api::parole.parole').validateParoles(data.titre, data.transcription)
|
||||||
|
|
||||||
if (ctx.request && ctx.request.header && ctx.request.header.authorization) {
|
if (ctx.request && ctx.request.header && ctx.request.header.authorization) {
|
||||||
try {
|
try {
|
||||||
@@ -87,11 +73,10 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
|
|||||||
|
|
||||||
|
|
||||||
if (user && user.canAutoTranslate && data.traductionAuto && data.traductions.francais && (!data.traductions.anglais || !data.traductions.espagnol || !data.traductions.allemand || !data.traductions.italien)) {
|
if (user && user.canAutoTranslate && data.traductionAuto && data.traductions.francais && (!data.traductions.anglais || !data.traductions.espagnol || !data.traductions.allemand || !data.traductions.italien)) {
|
||||||
const translated = await translateLyrics(data.traductions.francais)
|
const translated = await strapi.service('api::parole.parole').translateLyrics(data.traductions.francais)
|
||||||
data.traductions = translated
|
data.traductions = translated
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('data createCoreController', data)
|
|
||||||
const newParole = await strapi.entityService.create('api::parole.parole', {
|
const newParole = await strapi.entityService.create('api::parole.parole', {
|
||||||
data: {
|
data: {
|
||||||
...data
|
...data
|
||||||
|
|||||||
Reference in New Issue
Block a user