Fix creating error
This commit is contained in:
@@ -189,26 +189,28 @@ module.exports = {
|
|||||||
const user = await jwennUserEpiId(data?.user?.id)
|
const user = await jwennUserEpiId(data?.user?.id)
|
||||||
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
|
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
|
||||||
const superAdmin = await jwennSuperAdminEpiId(data?.createdBy)
|
const superAdmin = await jwennSuperAdminEpiId(data?.createdBy)
|
||||||
const traductionsId = data.traductions.id
|
const traductionsId = data?.traductions?.id
|
||||||
|
|
||||||
const result = await strapi.db.query('api::parole.parole').findOne({
|
if (traductionsId) {
|
||||||
where: {
|
const result = await strapi.db.query('api::parole.parole').findOne({
|
||||||
traductions: {
|
where: {
|
||||||
id: {
|
traductions: {
|
||||||
$eq: traductionsId
|
id: {
|
||||||
|
$eq: traductionsId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
populate: {traductions: true, artistes: true}
|
||||||
populate: {traductions: true, artistes: true}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (superAdmin && data.traductionAuto && result.traductions.francais && (!result.traductions.anglais || !result.traductions.espagnol || !result.traductions.allemand || !result.traductions.italien)) {
|
|
||||||
const traductions = await strapi.service('api::parole.parole').translateLyrics(result.traductions.francais)
|
|
||||||
await strapi.entityService.update('api::parole.parole', result.id, {
|
|
||||||
data: {
|
|
||||||
traductions
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (superAdmin && data.traductionAuto && result.traductions.francais && (!result.traductions.anglais || !result.traductions.espagnol || !result.traductions.allemand || !result.traductions.italien)) {
|
||||||
|
const traductions = await strapi.service('api::parole.parole').translateLyrics(result.traductions.francais)
|
||||||
|
await strapi.entityService.update('api::parole.parole', result.id, {
|
||||||
|
data: {
|
||||||
|
traductions
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user