mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-11 10:59:37 -06:00
Merge pull request #2021 from Vitordotpy/fix/message-update-and-i18n-errors
Some checks failed
Some checks failed
fix(baileys): message update and i18n errors
This commit is contained in:
commit
b62917e80f
@ -1498,7 +1498,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
`) as any[];
|
`) as any[];
|
||||||
findMessage = messages[0] || null;
|
findMessage = messages[0] || null;
|
||||||
|
|
||||||
if (findMessage) message.messageId = findMessage.id;
|
if (!findMessage?.id) {
|
||||||
|
this.logger.warn(`Original message not found for update. Skipping. Key: ${JSON.stringify(key)}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
message.messageId = findMessage.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update.message === null && update.status === undefined) {
|
if (update.message === null && update.status === undefined) {
|
||||||
|
|||||||
@ -3,14 +3,27 @@ import fs from 'fs';
|
|||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const __dirname = path.resolve(process.cwd(), 'src', 'utils');
|
const distPath = path.resolve(process.cwd(), 'dist', 'translations');
|
||||||
|
const srcPath = 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 translationsPath = path.join(__dirname, 'translations');
|
|
||||||
const configService: ConfigService = new ConfigService();
|
const configService: ConfigService = new ConfigService();
|
||||||
|
|
||||||
const resources: any = {};
|
const resources: any = {};
|
||||||
|
|
||||||
|
if (translationsPath) {
|
||||||
languages.forEach((language) => {
|
languages.forEach((language) => {
|
||||||
const languagePath = path.join(translationsPath, `${language}.json`);
|
const languagePath = path.join(translationsPath, `${language}.json`);
|
||||||
if (fs.existsSync(languagePath)) {
|
if (fs.existsSync(languagePath)) {
|
||||||
@ -20,6 +33,7 @@ languages.forEach((language) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
i18next.init({
|
i18next.init({
|
||||||
resources,
|
resources,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user