mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: Create instance with settings
This commit is contained in:
parent
62e2a8a6e3
commit
c314d00ccd
@ -13,6 +13,7 @@ import { Logger } from '../../config/logger.config';
|
|||||||
import { wa } from '../types/wa.types';
|
import { wa } from '../types/wa.types';
|
||||||
import { RedisCache } from '../../db/redis.client';
|
import { RedisCache } from '../../db/redis.client';
|
||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
|
import { SettingsService } from '../services/settings.service';
|
||||||
|
|
||||||
export class InstanceController {
|
export class InstanceController {
|
||||||
constructor(
|
constructor(
|
||||||
@ -23,6 +24,7 @@ export class InstanceController {
|
|||||||
private readonly authService: AuthService,
|
private readonly authService: AuthService,
|
||||||
private readonly webhookService: WebhookService,
|
private readonly webhookService: WebhookService,
|
||||||
private readonly chatwootService: ChatwootService,
|
private readonly chatwootService: ChatwootService,
|
||||||
|
private readonly settingsService: SettingsService,
|
||||||
private readonly cache: RedisCache,
|
private readonly cache: RedisCache,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -40,6 +42,12 @@ export class InstanceController {
|
|||||||
chatwoot_token,
|
chatwoot_token,
|
||||||
chatwoot_url,
|
chatwoot_url,
|
||||||
chatwoot_sign_msg,
|
chatwoot_sign_msg,
|
||||||
|
reject_call,
|
||||||
|
msg_call,
|
||||||
|
groups_ignore,
|
||||||
|
always_online,
|
||||||
|
read_messages,
|
||||||
|
read_status,
|
||||||
}: InstanceDto) {
|
}: InstanceDto) {
|
||||||
try {
|
try {
|
||||||
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
|
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
|
||||||
@ -102,6 +110,20 @@ export class InstanceController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.verbose('creating settings');
|
||||||
|
const settings: wa.LocalSettings = {
|
||||||
|
reject_call: reject_call || false,
|
||||||
|
msg_call: msg_call || '',
|
||||||
|
groups_ignore: groups_ignore || false,
|
||||||
|
always_online: always_online || false,
|
||||||
|
read_messages: read_messages || false,
|
||||||
|
read_status: read_status || false,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.logger.verbose('settings: ' + JSON.stringify(settings));
|
||||||
|
|
||||||
|
this.settingsService.create(instance, settings);
|
||||||
|
|
||||||
if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
|
if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
|
||||||
let getQrcode: wa.QrCode;
|
let getQrcode: wa.QrCode;
|
||||||
|
|
||||||
@ -121,6 +143,7 @@ export class InstanceController {
|
|||||||
webhook,
|
webhook,
|
||||||
webhook_by_events,
|
webhook_by_events,
|
||||||
events: getEvents,
|
events: getEvents,
|
||||||
|
settings,
|
||||||
qrcode: getQrcode,
|
qrcode: getQrcode,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -179,6 +202,7 @@ export class InstanceController {
|
|||||||
webhook,
|
webhook,
|
||||||
webhook_by_events,
|
webhook_by_events,
|
||||||
events: getEvents,
|
events: getEvents,
|
||||||
|
settings,
|
||||||
chatwoot: {
|
chatwoot: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
account_id: chatwoot_account_id,
|
account_id: chatwoot_account_id,
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
export class InstanceDto {
|
export class InstanceDto {
|
||||||
instanceName: string;
|
instanceName: string;
|
||||||
webhook?: string;
|
|
||||||
webhook_by_events?: boolean;
|
|
||||||
events?: string[];
|
|
||||||
qrcode?: boolean;
|
qrcode?: boolean;
|
||||||
number?: string;
|
number?: string;
|
||||||
token?: string;
|
token?: string;
|
||||||
|
webhook?: string;
|
||||||
|
webhook_by_events?: boolean;
|
||||||
|
events?: string[];
|
||||||
|
reject_call?: boolean;
|
||||||
|
msg_call?: string;
|
||||||
|
groups_ignore?: boolean;
|
||||||
|
always_online?: boolean;
|
||||||
|
read_messages?: boolean;
|
||||||
|
read_status?: boolean;
|
||||||
chatwoot_account_id?: string;
|
chatwoot_account_id?: string;
|
||||||
chatwoot_token?: string;
|
chatwoot_token?: string;
|
||||||
chatwoot_url?: string;
|
chatwoot_url?: string;
|
||||||
|
@ -94,6 +94,7 @@ export const instanceController = new InstanceController(
|
|||||||
authService,
|
authService,
|
||||||
webhookService,
|
webhookService,
|
||||||
chatwootService,
|
chatwootService,
|
||||||
|
settingsService,
|
||||||
cache,
|
cache,
|
||||||
);
|
);
|
||||||
export const viewsController = new ViewsController(waMonitor, configService);
|
export const viewsController = new ViewsController(waMonitor, configService);
|
||||||
|
Loading…
Reference in New Issue
Block a user