diff --git a/api/src/nlp/repositories/nlp-entity.repository.ts b/api/src/nlp/repositories/nlp-entity.repository.ts index 0bda7bfa..71d95487 100644 --- a/api/src/nlp/repositories/nlp-entity.repository.ts +++ b/api/src/nlp/repositories/nlp-entity.repository.ts @@ -48,7 +48,7 @@ export class NlpEntityRepository extends BaseRepository< * @param created - The newly created NLP entity document. */ async postCreate(_created: NlpEntityDocument): Promise { - if (!_created) { + if (!_created.builtin) { // Bypass builtin entities (probably fixtures) this.eventEmitter.emit('hook:nlpEntity:create', _created); } diff --git a/api/src/nlp/services/nlp.service.ts b/api/src/nlp/services/nlp.service.ts index 4b4cae0a..45e3a78c 100644 --- a/api/src/nlp/services/nlp.service.ts +++ b/api/src/nlp/services/nlp.service.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -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; @@ -104,9 +107,12 @@ export class NlpService { const helper = await this.helperService.getDefaultNluHelper(); const foreignId = await helper.addValue(value); this.logger.debug('New value successfully synced!', foreignId); - return await this.nlpValueService.updateOne(value._id, { - foreign_id: foreignId, - }); + return await this.nlpValueService.updateOne( + { _id: value._id }, + { + foreign_id: foreignId, + }, + ); } catch (err) { this.logger.error('Unable to sync a new value', err); return value;