Updated code

Using unedefined 'entry' variable is crashing the server
This commit is contained in:
Jozef Culen 2020-05-04 18:55:48 +02:00 committed by GitHub
parent 225ffecd7c
commit 08eeea7d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,10 +100,10 @@ module.exports = {
entity = await strapi.services.comment.create(ctx.request.body);
}
entry = sanitizeEntity(entity, { model: strapi.models.comment });
entity = sanitizeEntity(entity, { model: strapi.models.comment });
// check if the comment content contains a bad word
if (entry.content !== filter.clean(entry.content)) {
if (entity.content !== filter.clean(entity.content)) {
// send an email by using the email plugin
await strapi.plugins['email'].services.email.send({
@ -111,15 +111,15 @@ module.exports = {
from: 'admin@strapi.io'
subject: 'Comment posted that contains a bad words',
text: `
The comment #${entry.id} contain a bad words.
The comment #${entity.id} contain a bad words.
Comment:
${entry.content}
${entity.content}
`,
});
}
return entry;
return entity;
},
};
```