Skip to content

Commit f20fed6

Browse files
Merge pull request #940 from Hexastack/fix/sync-nlp-value
fix: correct criteria format for nlp value update
2 parents 5b2bfd0 + 7632866 commit f20fed6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

api/src/nlp/repositories/nlp-entity.repository.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class NlpEntityRepository extends BaseRepository<
4848
* @param created - The newly created NLP entity document.
4949
*/
5050
async postCreate(_created: NlpEntityDocument): Promise<void> {
51-
if (!_created) {
51+
if (!_created.builtin) {
5252
// Bypass builtin entities (probably fixtures)
5353
this.eventEmitter.emit('hook:nlpEntity:create', _created);
5454
}

api/src/nlp/services/nlp.service.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2024 Hexastack. All rights reserved.
2+
* Copyright © 2025 Hexastack. All rights reserved.
33
*
44
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
55
* 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 {
4242
const helper = await this.helperService.getDefaultNluHelper();
4343
const foreignId = await helper.addEntity(entity);
4444
this.logger.debug('New entity successfully synced!', foreignId);
45-
return await this.nlpEntityService.updateOne(entity._id, {
46-
foreign_id: foreignId,
47-
});
45+
return await this.nlpEntityService.updateOne(
46+
{ _id: entity._id },
47+
{
48+
foreign_id: foreignId,
49+
},
50+
);
4851
} catch (err) {
4952
this.logger.error('Unable to sync a new entity', err);
5053
return entity;
@@ -104,9 +107,12 @@ export class NlpService {
104107
const helper = await this.helperService.getDefaultNluHelper();
105108
const foreignId = await helper.addValue(value);
106109
this.logger.debug('New value successfully synced!', foreignId);
107-
return await this.nlpValueService.updateOne(value._id, {
108-
foreign_id: foreignId,
109-
});
110+
return await this.nlpValueService.updateOne(
111+
{ _id: value._id },
112+
{
113+
foreign_id: foreignId,
114+
},
115+
);
110116
} catch (err) {
111117
this.logger.error('Unable to sync a new value', err);
112118
return value;

0 commit comments

Comments
 (0)