@@ -13,6 +13,7 @@ import { Logger } from '../../config/logger.config';
1313import { wa } from '../types/wa.types' ;
1414import { RedisCache } from '../../db/redis.client' ;
1515import { isURL } from 'class-validator' ;
16+ import { SettingsService } from '../services/settings.service' ;
1617
1718export class InstanceController {
1819 constructor (
@@ -23,6 +24,7 @@ export class InstanceController {
2324 private readonly authService : AuthService ,
2425 private readonly webhookService : WebhookService ,
2526 private readonly chatwootService : ChatwootService ,
27+ private readonly settingsService : SettingsService ,
2628 private readonly cache : RedisCache ,
2729 ) { }
2830
@@ -40,6 +42,12 @@ export class InstanceController {
4042 chatwoot_token,
4143 chatwoot_url,
4244 chatwoot_sign_msg,
45+ reject_call,
46+ msg_call,
47+ groups_ignore,
48+ always_online,
49+ read_messages,
50+ read_status,
4351 } : InstanceDto ) {
4452 try {
4553 this . logger . verbose ( 'requested createInstance from ' + instanceName + ' instance' ) ;
@@ -102,6 +110,20 @@ export class InstanceController {
102110 }
103111 }
104112
113+ this . logger . verbose ( 'creating settings' ) ;
114+ const settings : wa . LocalSettings = {
115+ reject_call : reject_call || false ,
116+ msg_call : msg_call || '' ,
117+ groups_ignore : groups_ignore || false ,
118+ always_online : always_online || false ,
119+ read_messages : read_messages || false ,
120+ read_status : read_status || false ,
121+ } ;
122+
123+ this . logger . verbose ( 'settings: ' + JSON . stringify ( settings ) ) ;
124+
125+ this . settingsService . create ( instance , settings ) ;
126+
105127 if ( ! chatwoot_account_id || ! chatwoot_token || ! chatwoot_url ) {
106128 let getQrcode : wa . QrCode ;
107129
@@ -121,6 +143,7 @@ export class InstanceController {
121143 webhook,
122144 webhook_by_events,
123145 events : getEvents ,
146+ settings,
124147 qrcode : getQrcode ,
125148 } ;
126149
@@ -179,6 +202,7 @@ export class InstanceController {
179202 webhook,
180203 webhook_by_events,
181204 events : getEvents ,
205+ settings,
182206 chatwoot : {
183207 enabled : true ,
184208 account_id : chatwoot_account_id ,
0 commit comments