From 67c4aa640b726467810cefbeb0482fe882a47d6d Mon Sep 17 00:00:00 2001 From: OrionDesign Date: Thu, 11 Dec 2025 17:01:13 -0300 Subject: [PATCH] =?UTF-8?q?refactor(baileys):=20atualizar=20servi=C3=83?= =?UTF-8?q?=C2=A7o=20de=20mensagens=20e=20schemas=20de=20valida=C3=83?= =?UTF-8?q?=C2=A7=C3=83=C2=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 28 +++++ src/api/dto/chat.dto.ts | 2 +- .../whatsapp/whatsapp.baileys.service.ts | 116 +++++++++--------- src/validate/message.schema.ts | 2 +- 4 files changed, 90 insertions(+), 58 deletions(-) diff --git a/package-lock.json b/package-lock.json index c45e8fef..1aafeaba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2907,6 +2907,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=8.0.0" } @@ -2928,6 +2929,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-2.2.0.tgz", "integrity": "sha512-qRkLWiUEZNAmYapZ7KGS5C4OmBLcP/H2foXeOEaowYCR0wi89fHejrfYfbuLVCMLp/dWZXKvQusdbUEZjERfwQ==", "license": "Apache-2.0", + "peer": true, "engines": { "node": "^18.19.0 || >=20.6.0" }, @@ -2940,6 +2942,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.2.0.tgz", "integrity": "sha512-FuabnnUm8LflnieVxs6eP7Z383hgQU4W1e3KJS6aOG3RxWxcHyBxH8fDMHNgu/gFx/M2jvTOW/4/PHhLz6bjWw==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/semantic-conventions": "^1.29.0" }, @@ -2955,6 +2958,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.204.0.tgz", "integrity": "sha512-vV5+WSxktzoMP8JoYWKeopChy6G3HKk4UQ2hESCRDUUTZqQ3+nM3u8noVG0LmNfRWwcFBnbZ71GKC7vaYYdJ1g==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/api-logs": "0.204.0", "import-in-the-middle": "^1.8.1", @@ -3362,6 +3366,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.2.0.tgz", "integrity": "sha512-1pNQf/JazQTMA0BiO5NINUzH0cbLbbl7mntLa4aJNmCCXSj0q03T5ZXXL0zw4G55TjdL9Tz32cznGClf+8zr5A==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/semantic-conventions": "^1.29.0" @@ -3378,6 +3383,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.2.0.tgz", "integrity": "sha512-xWQgL0Bmctsalg6PaXExmzdedSp3gyKV8mQBwK/j9VGdCDu2fmXIb2gAehBKbkXCpJ4HPkgv3QfoJWRT4dHWbw==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/resources": "2.2.0", @@ -3395,6 +3401,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.38.0.tgz", "integrity": "sha512-kocjix+/sSggfJhwXqClZ3i9Y/MI0fp7b+g7kCRm6psy2dsf8uApTRclwG18h8Avm7C9+fnt+O36PspJ/OzoWg==", "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=14" } @@ -3643,6 +3650,7 @@ "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.1.tgz", "integrity": "sha512-/KCsg3xSlR+nCK8/8ZYSknYxvXHwubJrU82F3Lm1Fp6789VQ0/3RJKfsmRXjqfaTA++23CvC3hqmqe/2GEt6Kw==", "license": "MIT", + "peer": true, "dependencies": { "cluster-key-slot": "1.1.2", "generic-pool": "3.9.0", @@ -4933,6 +4941,7 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -5108,6 +5117,7 @@ "integrity": "sha512-lJi3PfxVmo0AkEY93ecfN+r8SofEqZNGByvHAI3GBLrvt1Cw6H5k1IM02nSzu0RfUafr2EvFSw0wAsZgubNplQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.47.0", "@typescript-eslint/types": "8.47.0", @@ -5411,6 +5421,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5758,6 +5769,7 @@ "resolved": "https://registry.npmjs.org/audio-decode/-/audio-decode-2.2.3.tgz", "integrity": "sha512-Z0lHvMayR/Pad9+O9ddzaBJE0DrhZkQlStrC1RwcAHF3AhQAsdwKHeLGK8fYKyp2DDU6xHxzGb4CLMui12yVrg==", "license": "MIT", + "peer": true, "dependencies": { "@wasm-audio-decoders/flac": "^0.2.4", "@wasm-audio-decoders/ogg-vorbis": "^0.1.15", @@ -6746,6 +6758,7 @@ "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "env-paths": "^2.2.1", "import-fresh": "^3.3.0", @@ -7636,6 +7649,7 @@ "integrity": "sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==", "hasInstallScript": true, "license": "MIT", + "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -7706,6 +7720,7 @@ "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -7762,6 +7777,7 @@ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", + "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -8368,6 +8384,7 @@ "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "license": "MIT", + "peer": true, "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -10355,6 +10372,7 @@ "resolved": "https://registry.npmjs.org/jimp/-/jimp-1.6.0.tgz", "integrity": "sha512-YcwCHw1kiqEeI5xRpDlPPBGL2EOpBKLwO4yIBJcXWHPj5PnA5urGq0jbyhM5KoNpypQ6VboSoxc9D8HyfvngSg==", "license": "MIT", + "peer": true, "dependencies": { "@jimp/core": "1.6.0", "@jimp/diff": "1.6.0", @@ -10585,6 +10603,7 @@ "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.5.4.tgz", "integrity": "sha512-eohl3hKTiVyD1ilYdw9T0OiB4hnjef89e3dMYKz+mVKDzj+5IteTseASUsOB+EU9Tf6VNTCjDePcP6wkDGmLKQ==", "license": "MIT", + "peer": true, "dependencies": { "@keyv/serialize": "^1.1.1" } @@ -10680,6 +10699,7 @@ "resolved": "https://registry.npmjs.org/link-preview-js/-/link-preview-js-3.2.0.tgz", "integrity": "sha512-FvrLltjOPGbTzt+RugbzM7g8XuUNLPO2U/INSLczrYdAA32E7nZVUrVL1gr61DGOArGJA2QkPGMEvNMLLsXREA==", "license": "MIT", + "peer": true, "dependencies": { "cheerio": "1.0.0-rc.11", "url": "0.11.0" @@ -12600,6 +12620,7 @@ "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", "license": "MIT", + "peer": true, "dependencies": { "pg-connection-string": "^2.9.1", "pg-pool": "^3.10.1", @@ -12909,6 +12930,7 @@ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -12938,6 +12960,7 @@ "integrity": "sha512-F3eX7K+tWpkbhl3l4+VkFtrwJlLXbAM+f9jolgoUZbFcm1DgHZ4cq9AgVEgUym2au5Ad/TDLN8lg83D+M10ycw==", "hasInstallScript": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@prisma/config": "6.19.0", "@prisma/engines": "6.19.0" @@ -14029,6 +14052,7 @@ "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", "hasInstallScript": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@img/colour": "^1.0.0", "detect-libc": "^2.1.2", @@ -14871,6 +14895,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -15059,6 +15084,7 @@ "integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "~0.25.0", "get-tsconfig": "^4.7.5" @@ -15707,6 +15733,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -16222,6 +16249,7 @@ "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", "devOptional": true, "license": "ISC", + "peer": true, "bin": { "yaml": "bin.mjs" }, diff --git a/src/api/dto/chat.dto.ts b/src/api/dto/chat.dto.ts index a8098729..aeaab6f8 100644 --- a/src/api/dto/chat.dto.ts +++ b/src/api/dto/chat.dto.ts @@ -135,4 +135,4 @@ export class DecryptPollVoteDto { }; }; remoteJid: string; -} \ No newline at end of file +} diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 1b678ad9..81913847 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -733,7 +733,7 @@ export class BaileysStartupService extends ChannelStartupService { }); return await this.createClient(number); - } catch (error) { + } catch { this.logger.error(error); throw new InternalServerErrorException(error?.toString()); } @@ -742,7 +742,7 @@ export class BaileysStartupService extends ChannelStartupService { public async reloadConnection(): Promise { try { return await this.createClient(this.phoneNumber); - } catch (error) { + } catch { this.logger.error(error); throw new InternalServerErrorException(error?.toString()); } @@ -888,7 +888,7 @@ export class BaileysStartupService extends ChannelStartupService { }), ); } - } catch (error) { + } catch { console.error(error); this.logger.error(`Error: ${error.message}`); } @@ -1074,7 +1074,7 @@ export class BaileysStartupService extends ChannelStartupService { contacts = undefined; messages = undefined; chats = undefined; - } catch (error) { + } catch { this.logger.error(error); } }, @@ -1434,7 +1434,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.prismaRepository.message.update({ where: { id: msg.id }, data: messageRaw }); } - } catch (error) { + } catch { this.logger.error(['Error on upload file to minio', error?.message, error?.stack]); } } @@ -1466,7 +1466,7 @@ export class BaileysStartupService extends ChannelStartupService { messageRaw.message.base64 = buffer.toString('base64'); } } - } catch (error) { + } catch { this.logger.error(['Error converting media to base64', error?.message]); } } @@ -1550,7 +1550,7 @@ export class BaileysStartupService extends ChannelStartupService { create: contactRaw, }); } - } catch (error) { + } catch { this.logger.error(error); } }, @@ -1798,7 +1798,7 @@ export class BaileysStartupService extends ChannelStartupService { }; this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, enhancedParticipantsUpdate); - } catch (error) { + } catch { this.logger.error( `Failed to resolve participant data for GROUP_PARTICIPANTS_UPDATE webhook: ${error.message} | Group: ${participantsUpdate.id} | Participants: ${participantsUpdate.participants.length}`, ); @@ -2005,7 +2005,7 @@ export class BaileysStartupService extends ChannelStartupService { return; } } - } catch (error) { + } catch { this.logger.error(error); } }); @@ -2122,7 +2122,7 @@ export class BaileysStartupService extends ChannelStartupService { // return call; return { id: '123', jid, isVideo, callDuration }; - } catch (error) { + } catch { return error; } } @@ -2503,7 +2503,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.prismaRepository.message.update({ where: { id: msg.id }, data: messageRaw }); } - } catch (error) { + } catch { this.logger.error(['Error on upload file to minio', error?.message, error?.stack]); } } @@ -2534,7 +2534,7 @@ export class BaileysStartupService extends ChannelStartupService { messageRaw.message.base64 = buffer.toString('base64'); } } - } catch (error) { + } catch { this.logger.error(['Error converting media to base64', error?.message]); } } @@ -2555,7 +2555,7 @@ export class BaileysStartupService extends ChannelStartupService { } return messageRaw; - } catch (error) { + } catch { this.logger.error(error); throw new BadRequestException(error.toString()); } @@ -2607,7 +2607,7 @@ export class BaileysStartupService extends ChannelStartupService { } return { presence: data.presence }; - } catch (error) { + } catch { this.logger.error(error); throw new BadRequestException(error.toString()); } @@ -2619,7 +2619,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.sendPresenceUpdate(data.presence); return { presence: data.presence }; - } catch (error) { + } catch { this.logger.error(error); throw new BadRequestException(error.toString()); } @@ -2860,7 +2860,7 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.verbose(`Video duration: ${duration} seconds`); prepareMedia[mediaType].seconds = duration; - } catch (error) { + } catch { this.logger.error('Error getting video duration:'); this.logger.error(error); throw new Error(`Failed to get video duration: ${error.message}`); @@ -2887,7 +2887,7 @@ export class BaileysStartupService extends ChannelStartupService { { [mediaType]: { ...prepareMedia[mediaType] } }, { userJid: this.instance.wuid }, ); - } catch (error) { + } catch { this.logger.error(error); throw new InternalServerErrorException(error?.toString() || error); } @@ -2932,7 +2932,7 @@ export class BaileysStartupService extends ChannelStartupService { } else { return await sharp(imageBuffer).webp().toBuffer(); } - } catch (error) { + } catch { console.error('Erro ao converter a imagem para WebP:', error); throw error; } @@ -3683,7 +3683,7 @@ export class BaileysStartupService extends ChannelStartupService { }); await this.client.readMessages(keys); return { message: 'Read messages', read: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Read messages fail', error.toString()); } } @@ -3732,7 +3732,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.chatModify({ archive: data.archive, lastMessages: [last_message] }, createJid(number)); return { chatId: number, archived: true }; - } catch (error) { + } catch { throw new InternalServerErrorException({ archived: false, message: ['An error occurred while archiving the chat. Open a calling.', error.toString()], @@ -3760,7 +3760,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.chatModify({ markRead: false, lastMessages: [last_message] }, createJid(number)); return { chatId: number, markedChatUnread: true }; - } catch (error) { + } catch { throw new InternalServerErrorException({ markedChatUnread: false, message: ['An error occurred while marked unread the chat. Open a calling.', error.toString()], @@ -3817,7 +3817,7 @@ export class BaileysStartupService extends ChannelStartupService { } return response; - } catch (error) { + } catch { throw new InternalServerErrorException('Error while deleting message for everyone', error?.toString()); } } @@ -3955,7 +3955,7 @@ export class BaileysStartupService extends ChannelStartupService { return result; } - } catch (error) { + } catch { this.logger.error('Error converting audio to mp4:'); this.logger.error(error); throw new BadRequestException('Failed to convert audio to MP4'); @@ -3971,7 +3971,7 @@ export class BaileysStartupService extends ChannelStartupService { base64: buffer.toString('base64'), buffer: getBuffer ? buffer : null, }; - } catch (error) { + } catch { this.logger.error('Error processing media message:'); this.logger.error(error); throw new BadRequestException(error.toString()); @@ -4013,7 +4013,7 @@ export class BaileysStartupService extends ChannelStartupService { groupadd: settings.groupadd, }, }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating privacy settings', error.toString()); } } @@ -4031,7 +4031,7 @@ export class BaileysStartupService extends ChannelStartupService { } return { isBusiness: true, ...profile }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating profile name', error.toString()); } } @@ -4041,7 +4041,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.updateProfileName(name); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating profile name', error.toString()); } } @@ -4051,7 +4051,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.updateProfileStatus(status); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating profile status', error.toString()); } } @@ -4092,7 +4092,7 @@ export class BaileysStartupService extends ChannelStartupService { this.reloadConnection(); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating profile picture', error.toString()); } } @@ -4104,7 +4104,7 @@ export class BaileysStartupService extends ChannelStartupService { this.reloadConnection(); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error removing profile picture', error.toString()); } } @@ -4124,7 +4124,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.updateBlockStatus(sender, data.status); return { block: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error blocking user', error.toString()); } } @@ -4150,7 +4150,7 @@ export class BaileysStartupService extends ChannelStartupService { } return null; - } catch (error) { + } catch { this.logger.error(error); throw new BadRequestException(error.toString()); } @@ -4238,7 +4238,7 @@ export class BaileysStartupService extends ChannelStartupService { } return messageSent; - } catch (error) { + } catch { this.logger.error(error); throw error; } @@ -4278,7 +4278,7 @@ export class BaileysStartupService extends ChannelStartupService { return { numberJid: contact.jid, labelId: data.labelId, remove: true }; } - } catch (error) { + } catch { throw new BadRequestException(`Unable to ${data.action} label to chat`, error.toString()); } } @@ -4296,7 +4296,7 @@ export class BaileysStartupService extends ChannelStartupService { } return meta; - } catch (error) { + } catch { this.logger.error(error); return null; } @@ -4344,7 +4344,7 @@ export class BaileysStartupService extends ChannelStartupService { const group = await this.client.groupMetadata(id); return group; - } catch (error) { + } catch { this.logger.error(error); throw new InternalServerErrorException('Error creating group', error.toString()); } @@ -4383,7 +4383,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.updateProfilePicture(picture.groupJid, pic); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error update group picture', error.toString()); } } @@ -4393,7 +4393,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.groupUpdateSubject(data.groupJid, data.subject); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating group subject', error.toString()); } } @@ -4403,7 +4403,7 @@ export class BaileysStartupService extends ChannelStartupService { await this.client.groupUpdateDescription(data.groupJid, data.description); return { update: 'success' }; - } catch (error) { + } catch { throw new InternalServerErrorException('Error updating group description', error.toString()); } } @@ -4437,7 +4437,7 @@ export class BaileysStartupService extends ChannelStartupService { isCommunityAnnounce: group.isCommunityAnnounce, linkedParent: group.linkedParent, }; - } catch (error) { + } catch { if (reply === 'inner') { return; } @@ -4484,7 +4484,7 @@ export class BaileysStartupService extends ChannelStartupService { try { const code = await this.client.groupInviteCode(id.groupJid); return { inviteUrl: `https://chat.whatsapp.com/${code}`, inviteCode: code }; - } catch (error) { + } catch { throw new NotFoundException('No invite code', error.toString()); } } @@ -4524,7 +4524,7 @@ export class BaileysStartupService extends ChannelStartupService { try { const groupJid = await this.client.groupAcceptInvite(id.inviteCode); return { accepted: true, groupJid: groupJid }; - } catch (error) { + } catch { throw new NotFoundException('Accept invite error', error.toString()); } } @@ -4533,7 +4533,7 @@ export class BaileysStartupService extends ChannelStartupService { try { const inviteCode = await this.client.groupRevokeInvite(id.groupJid); return { revoked: true, inviteCode }; - } catch (error) { + } catch { throw new NotFoundException('Revoke error', error.toString()); } } @@ -4559,7 +4559,7 @@ export class BaileysStartupService extends ChannelStartupService { } return { participants: parsedParticipants }; - } catch (error) { + } catch { console.error(error); throw new NotFoundException('No participants', error.toString()); } @@ -4574,7 +4574,7 @@ export class BaileysStartupService extends ChannelStartupService { update.action, ); return { updateParticipants: updateParticipants }; - } catch (error) { + } catch { throw new BadRequestException('Error updating participants', error.toString()); } } @@ -4583,7 +4583,7 @@ export class BaileysStartupService extends ChannelStartupService { try { const updateSetting = await this.client.groupSettingUpdate(update.groupJid, update.action); return { updateSetting: updateSetting }; - } catch (error) { + } catch { throw new BadRequestException('Error updating setting', error.toString()); } } @@ -4592,7 +4592,7 @@ export class BaileysStartupService extends ChannelStartupService { try { await this.client.groupToggleEphemeral(update.groupJid, update.expiration); return { success: true }; - } catch (error) { + } catch { throw new BadRequestException('Error updating setting', error.toString()); } } @@ -4601,7 +4601,7 @@ export class BaileysStartupService extends ChannelStartupService { try { await this.client.groupLeave(id.groupJid); return { groupJid: id.groupJid, leave: true }; - } catch (error) { + } catch { throw new BadRequestException('Unable to leave the group', error.toString()); } } @@ -4885,7 +4885,7 @@ export class BaileysStartupService extends ChannelStartupService { const response = await this.client.signalRepository.decryptMessage({ jid, type, ciphertext: ciphertextBuffer }); return response instanceof Uint8Array ? Buffer.from(response).toString('base64') : response; - } catch (error) { + } catch { this.logger.error('Error decrypting message:'); this.logger.error(error); throw error; @@ -4943,7 +4943,7 @@ export class BaileysStartupService extends ChannelStartupService { catalogLength: productsCatalog.length, catalog: productsCatalog, }; - } catch (error) { + } catch { console.log(error); return { wuid: jid, name: null, isBusiness: false }; } @@ -4964,7 +4964,7 @@ export class BaileysStartupService extends ChannelStartupService { } return catalog; - } catch (error) { + } catch { throw new InternalServerErrorException('Error getCatalog', error.toString()); } } @@ -5008,7 +5008,7 @@ export class BaileysStartupService extends ChannelStartupService { } return result.collections; - } catch (error) { + } catch { throw new InternalServerErrorException('Error getCatalog', error.toString()); } } @@ -5238,7 +5238,9 @@ export class BaileysStartupService extends ChannelStartupService { // Já está descriptografado como nomes de opções selectedOptionNames = selectedOptions; successfulVoterJid = uniqueVoters[0]; - this.logger.verbose(`Using already decrypted vote: voter=${successfulVoterJid}, options=${selectedOptionNames.join(',')}`); + this.logger.verbose( + `Using already decrypted vote: voter=${successfulVoterJid}, options=${selectedOptionNames.join(',')}`, + ); } else { // Está como hash, precisa converter para nomes selectedOptionNames = pollOptions @@ -5272,7 +5274,7 @@ export class BaileysStartupService extends ChannelStartupService { successfulVoterJid = voter; break; } - } catch (error) { + } catch { // Continue tentando outras combinações } } @@ -5293,7 +5295,9 @@ export class BaileysStartupService extends ChannelStartupService { }) .map((option: any) => option.optionName); - this.logger.verbose(`Successfully decrypted vote for voter: ${successfulVoterJid}, creator: ${uniqueCreators[0]}`); + this.logger.verbose( + `Successfully decrypted vote for voter: ${successfulVoterJid}, creator: ${uniqueCreators[0]}`, + ); } else { this.logger.warn(`Failed to decrypt vote. Last error: Could not decrypt with any combination`); continue; @@ -5357,7 +5361,7 @@ export class BaileysStartupService extends ChannelStartupService { results, }, }; - } catch (error) { + } catch { this.logger.error(`Error decrypting poll votes: ${error}`); throw new InternalServerErrorException('Error decrypting poll votes', error.toString()); } diff --git a/src/validate/message.schema.ts b/src/validate/message.schema.ts index aef922cd..6970fd9b 100644 --- a/src/validate/message.schema.ts +++ b/src/validate/message.schema.ts @@ -468,4 +468,4 @@ export const decryptPollVoteSchema: JSONSchema7 = { remoteJid: { type: 'string' }, }, required: ['message', 'remoteJid'], -}; \ No newline at end of file +};