Remove translateLyrics from parole lifecycles and fix validateParoles
This commit is contained in:
@@ -76,21 +76,6 @@ const jwennUserAdminEpiId = async userAdminId => {
|
||||
return userAdmin
|
||||
}
|
||||
|
||||
const translateLyrics = async parolesFR => {
|
||||
const anglais = await strapi.services.translator.translate('FR', 'EN', parolesFR)
|
||||
const espagnol = await strapi.services.translator.translate('FR', 'ES', parolesFR)
|
||||
const allemand = await strapi.services.translator.translate('FR', 'DE', parolesFR)
|
||||
const italien = await strapi.services.translator.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 validateParoles = (titre, transcription) => {
|
||||
if (!titre || titre.trim().length === 0) {
|
||||
throw new ValidationError('Champ obligatoire. Veuillez choisir un titre.');
|
||||
@@ -110,7 +95,6 @@ module.exports = {
|
||||
let {data} = event.params
|
||||
validateParoles(data.titre, data.transcription)
|
||||
|
||||
const user = await jwennUserEpiId(data?.user?.id)
|
||||
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
|
||||
|
||||
if (userAdmin) {
|
||||
@@ -127,19 +111,12 @@ module.exports = {
|
||||
if (getSlugExistance) {
|
||||
throw new ValidationError('Un morceau du même artiste existe déjà.')
|
||||
}
|
||||
|
||||
if (user && user.canAutoTranslate && data.traductionAuto && data.titre.francais && (!data.transcription.english || !data.transcription.espagnol || !data.transcription.deutsch || !data.transcription.italiano)) {
|
||||
const translated = await translateLyrics(data.traduction.francais)
|
||||
data.traductions = translated
|
||||
}
|
||||
|
||||
},
|
||||
beforeUpdate: async event => {
|
||||
let {data} = event.params
|
||||
const {where} = event.params
|
||||
|
||||
|
||||
if(!data.publishedAt) {
|
||||
if(!data.publishedAt && data.titre && data.transcription) {
|
||||
validateParoles(data.titre, data.transcription)
|
||||
if (data.titre && !data.forceSlug) {
|
||||
const artiste = await jwennAwtisEpiId(data.artistes)
|
||||
|
||||
Reference in New Issue
Block a user