mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-09 01:49:37 -06:00
fix(baileys): adicionar log de aviso para mensagens não encontradas
- Implementada uma mensagem de aviso no serviço Baileys quando a mensagem original não é encontrada durante a atualização, melhorando a rastreabilidade de erros. - Ajustada a lógica de verificação do caminho de traduções para garantir que o diretório correto seja utilizado, com tratamento de erro caso não seja encontrado.
This commit is contained in:
parent
c31b62fb3d
commit
eeb324227b
@ -1499,6 +1499,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
findMessage = messages[0] || null;
|
findMessage = messages[0] || null;
|
||||||
|
|
||||||
if (!findMessage?.id) {
|
if (!findMessage?.id) {
|
||||||
|
this.logger.warn(`Original message not found for update. Skipping. Key: ${JSON.stringify(key)}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
message.messageId = findMessage.id;
|
message.messageId = findMessage.id;
|
||||||
|
|||||||
@ -3,24 +3,37 @@ import fs from 'fs';
|
|||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const translationsPath = fs.existsSync(path.resolve(process.cwd(), 'dist'))
|
const distPath = path.resolve(process.cwd(), 'dist', 'translations');
|
||||||
? path.resolve(process.cwd(), 'dist', 'translations')
|
const srcPath = path.resolve(process.cwd(), 'src', 'utils', 'translations');
|
||||||
: path.resolve(process.cwd(), 'src', 'utils', 'translations');
|
|
||||||
|
let translationsPath;
|
||||||
|
|
||||||
|
if (fs.existsSync(distPath)) {
|
||||||
|
translationsPath = distPath;
|
||||||
|
} else if (fs.existsSync(srcPath)) {
|
||||||
|
translationsPath = srcPath;
|
||||||
|
} else {
|
||||||
|
console.error('Translations directory not found in dist or src.');
|
||||||
|
// Fallback to a non-existent path or handle error appropriately
|
||||||
|
translationsPath = '';
|
||||||
|
}
|
||||||
|
|
||||||
const languages = ['en', 'pt-BR', 'es'];
|
const languages = ['en', 'pt-BR', 'es'];
|
||||||
const configService: ConfigService = new ConfigService();
|
const configService: ConfigService = new ConfigService();
|
||||||
|
|
||||||
const resources: any = {};
|
const resources: any = {};
|
||||||
|
|
||||||
languages.forEach((language) => {
|
if (translationsPath) {
|
||||||
const languagePath = path.join(translationsPath, `${language}.json`);
|
languages.forEach((language) => {
|
||||||
if (fs.existsSync(languagePath)) {
|
const languagePath = path.join(translationsPath, `${language}.json`);
|
||||||
const translationContent = fs.readFileSync(languagePath, 'utf8');
|
if (fs.existsSync(languagePath)) {
|
||||||
resources[language] = {
|
const translationContent = fs.readFileSync(languagePath, 'utf8');
|
||||||
translation: JSON.parse(translationContent),
|
resources[language] = {
|
||||||
};
|
translation: JSON.parse(translationContent),
|
||||||
}
|
};
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
i18next.init({
|
i18next.init({
|
||||||
resources,
|
resources,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user