fix: correct criteria format and correct postCreate hook event

This commit is contained in:
MohamedAliBouhaouala
2025-04-17 14:48:50 +01:00
parent b04673fab4
commit 7632866b2a
2 changed files with 7 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ export class NlpEntityRepository extends BaseRepository<
* @param created - The newly created NLP entity document.
*/
async postCreate(_created: NlpEntityDocument): Promise<void> {
if (!_created) {
if (!_created.builtin) {
// Bypass builtin entities (probably fixtures)
this.eventEmitter.emit('hook:nlpEntity:create', _created);
}

View File

@@ -42,9 +42,12 @@ export class NlpService {
const helper = await this.helperService.getDefaultNluHelper();
const foreignId = await helper.addEntity(entity);
this.logger.debug('New entity successfully synced!', foreignId);
return await this.nlpEntityService.updateOne(entity._id, {
foreign_id: foreignId,
});
return await this.nlpEntityService.updateOne(
{ _id: entity._id },
{
foreign_id: foreignId,
},
);
} catch (err) {
this.logger.error('Unable to sync a new entity', err);
return entity;