feat: Route to update the privacy settings

This commit is contained in:
Davidson Gomes 2023-06-11 19:24:19 -03:00
parent ab28b4c0c5
commit 573e56cd8c

View File

@ -213,87 +213,98 @@ export class WAStartupService {
} }
public async sendDataWebhook<T = any>(event: Events, data: T, local = true) { public async sendDataWebhook<T = any>(event: Events, data: T, local = true) {
// const webhook = this.configService.get<Webhook>('WEBHOOK'); const webhook = this.configService.get<Webhook>('WEBHOOK');
// const we = event.replace(/[\.-]/gm, '_').toUpperCase(); const we = event.replace(/[\.-]/gm, '_').toUpperCase();
// const transformedWe = we.replace(/_/gm, '-').toLowerCase(); const transformedWe = we.replace(/_/gm, '-').toLowerCase();
// const instance = this.configService.get<Auth>('AUTHENTICATION').INSTANCE; const instance = this.configService.get<Auth>('AUTHENTICATION').INSTANCE;
// if (webhook.EVENTS[we]) {
// if (local && instance.MODE !== 'container') { if (webhook.EVENTS[we]) {
// const { WEBHOOK_BY_EVENTS } = instance; if (local && instance.MODE !== 'container') {
// let baseURL; const { WEBHOOK_BY_EVENTS } = instance;
// if (WEBHOOK_BY_EVENTS) {
// baseURL = `${this.localWebhook.url}/${transformedWe}`; let baseURL;
// } else {
// baseURL = this.localWebhook.url; if (WEBHOOK_BY_EVENTS) {
// } baseURL = `${this.localWebhook.url}/${transformedWe}`;
// try { } else {
// if (this.localWebhook.enabled && isURL(this.localWebhook.url)) { baseURL = this.localWebhook.url;
// const httpService = axios.create({ baseURL }); }
// await httpService.post('', {
// event, try {
// instance: this.instance.name, if (this.localWebhook.enabled && isURL(this.localWebhook.url)) {
// data, const httpService = axios.create({ baseURL });
// destination: this.localWebhook.url, await httpService.post('', {
// }); event,
// } instance: this.instance.name,
// } catch (error) { data,
// this.logger.error({ destination: this.localWebhook.url,
// local: WAStartupService.name + '.sendDataWebhook-local', });
// message: error?.message, }
// hostName: error?.hostname, } catch (error) {
// syscall: error?.syscall, this.logger.error({
// code: error?.code, local: WAStartupService.name + '.sendDataWebhook-local',
// error: error?.errno, message: error?.message,
// stack: error?.stack, hostName: error?.hostname,
// name: error?.name, syscall: error?.syscall,
// url: baseURL, code: error?.code,
// }); error: error?.errno,
// } stack: error?.stack,
// } name: error?.name,
// const globalWebhook = this.configService.get<Webhook>('WEBHOOK').GLOBAL; url: baseURL,
// let globalURL; });
// if (webhook.GLOBAL.WEBHOOK_BY_EVENTS) { }
// globalURL = `${globalWebhook.URL}/${transformedWe}`; }
// } else {
// globalURL = globalWebhook.URL; const globalWebhook = this.configService.get<Webhook>('WEBHOOK').GLOBAL;
// }
// let localUrl; let globalURL;
// if (instance.MODE === 'container') {
// localUrl = instance.WEBHOOK_URL; if (webhook.GLOBAL.WEBHOOK_BY_EVENTS) {
// } else { globalURL = `${globalWebhook.URL}/${transformedWe}`;
// localUrl = this.localWebhook.url; } else {
// } globalURL = globalWebhook.URL;
// this.logger.log({ }
// url: globalURL,
// event, let localUrl;
// instance: this.instance.name,
// data, if (instance.MODE === 'container') {
// destination: localUrl, localUrl = instance.WEBHOOK_URL;
// }); } else {
// try { localUrl = this.localWebhook.url;
// if (globalWebhook && globalWebhook?.ENABLED && isURL(globalURL)) { }
// const httpService = axios.create({ baseURL: globalURL });
// await httpService.post('', { this.logger.log({
// event, url: globalURL,
// instance: this.instance.name, event,
// data, instance: this.instance.name,
// destination: localUrl, data,
// }); destination: localUrl,
// } });
// } catch (error) {
// this.logger.error({ try {
// local: WAStartupService.name + '.sendDataWebhook-global', if (globalWebhook && globalWebhook?.ENABLED && isURL(globalURL)) {
// message: error?.message, const httpService = axios.create({ baseURL: globalURL });
// hostName: error?.hostname, await httpService.post('', {
// syscall: error?.syscall, event,
// code: error?.code, instance: this.instance.name,
// error: error?.errno, data,
// stack: error?.stack, destination: localUrl,
// name: error?.name, });
// url: globalURL, }
// }); } catch (error) {
// } this.logger.error({
// } local: WAStartupService.name + '.sendDataWebhook-global',
message: error?.message,
hostName: error?.hostname,
syscall: error?.syscall,
code: error?.code,
error: error?.errno,
stack: error?.stack,
name: error?.name,
url: globalURL,
});
}
}
} }
private async connectionUpdate({ private async connectionUpdate({
@ -455,7 +466,7 @@ export class WAStartupService {
const { version } = await fetchLatestBaileysVersion(); const { version } = await fetchLatestBaileysVersion();
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE'); const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()]; const browser: WABrowserDescription = [session.CLIENT, 'Chrome', release()];
const socketConfig: UserFacingSocketConfig = { const socketConfig: UserFacingSocketConfig = {
auth: { auth: {