Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/api/controllers/contact.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { SaveContactDto } from '@api/dto/contact.dto';
import { InstanceDto } from '@api/dto/instance.dto';
import { WAMonitoringService } from '@api/services/monitor.service';
import { BadRequestException } from '@exceptions';

export class ContactController {
constructor(private readonly waMonitor: WAMonitoringService) {}

public async saveContact({ instanceName }: InstanceDto, data: SaveContactDto) {
const instance = this.waMonitor.waInstances[instanceName];

if (!instance || typeof (instance as any).saveContact !== 'function') {
throw new BadRequestException(

Check failure on line 13 in src/api/controllers/contact.controller.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `␍⏎········`saveContact·is·not·supported·for·the·provider·used·by·instance·"${instanceName}"`,␍⏎······` with ``saveContact·is·not·supported·for·the·provider·used·by·instance·"${instanceName}"``
`saveContact is not supported for the provider used by instance "${instanceName}"`,
);
}

return await (instance as any).saveContact(data);
}
}
5 changes: 5 additions & 0 deletions src/api/dto/contact.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class SaveContactDto {
number: string;
name: string;
saveOnDevice?: boolean;
}
Loading
Loading