mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-24 22:27:46 -06:00
fix: Fixed the problem when do not save contacts when receive messages
This commit is contained in:
@@ -53,6 +53,40 @@ export class ContactRepository extends Repository {
|
||||
}
|
||||
}
|
||||
|
||||
public async update(
|
||||
data: ContactRaw,
|
||||
instanceName: string,
|
||||
saveDb = false,
|
||||
): Promise<IInsert> {
|
||||
try {
|
||||
if (this.dbSettings.ENABLED && saveDb) {
|
||||
const contact = await this.contactModel.findOneAndUpdate(
|
||||
{ id: data.id },
|
||||
{ ...data },
|
||||
);
|
||||
return { insertCount: contact ? 1 : 0 };
|
||||
}
|
||||
|
||||
const store = this.configService.get<StoreConf>('STORE');
|
||||
|
||||
if (store.CONTACTS) {
|
||||
this.writeStore({
|
||||
path: join(this.storePath, 'contacts', instanceName),
|
||||
fileName: data.id,
|
||||
data,
|
||||
});
|
||||
|
||||
return { insertCount: 1 };
|
||||
}
|
||||
|
||||
return { insertCount: 0 };
|
||||
} catch (error) {
|
||||
return error;
|
||||
} finally {
|
||||
data = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
public async find(query: ContactQuery): Promise<ContactRaw[]> {
|
||||
try {
|
||||
if (this.dbSettings.ENABLED) {
|
||||
|
||||
Reference in New Issue
Block a user