mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-24 06:07:45 -06:00
feat(IsOnWhatsapp): add optional lid field and update related logic
- Introduced a new optional `lid` field in the IsOnWhatsapp model to enhance data tracking. - Updated migration script to add the `lid` column to the database. - Modified OnWhatsAppDto to include the `lid` property for better integration with WhatsApp user data. - Enhanced the WhatsApp Baileys service to handle `lid` numbers separately and improve user verification logic. - Updated cache handling functions to support the new `lid` field for consistent data management.
This commit is contained in:
@@ -52,7 +52,9 @@ function getAvailableNumbers(remoteJid: string) {
|
||||
|
||||
interface ISaveOnWhatsappCacheParams {
|
||||
remoteJid: string;
|
||||
lid?: string;
|
||||
}
|
||||
|
||||
export async function saveOnWhatsappCache(data: ISaveOnWhatsappCacheParams[]) {
|
||||
if (configService.get<Database>('DATABASE').SAVE_DATA.IS_ON_WHATSAPP) {
|
||||
const upsertsQuery = data.map((item) => {
|
||||
@@ -60,8 +62,15 @@ export async function saveOnWhatsappCache(data: ISaveOnWhatsappCacheParams[]) {
|
||||
const numbersAvailable = getAvailableNumbers(remoteJid);
|
||||
|
||||
return prismaRepository.isOnWhatsapp.upsert({
|
||||
create: { remoteJid: remoteJid, jidOptions: numbersAvailable.join(',') },
|
||||
update: { jidOptions: numbersAvailable.join(',') },
|
||||
create: {
|
||||
remoteJid: remoteJid,
|
||||
jidOptions: numbersAvailable.join(','),
|
||||
lid: item.lid,
|
||||
},
|
||||
update: {
|
||||
jidOptions: numbersAvailable.join(','),
|
||||
lid: item.lid,
|
||||
},
|
||||
where: { remoteJid: remoteJid },
|
||||
});
|
||||
});
|
||||
@@ -75,6 +84,7 @@ export async function getOnWhatsappCache(remoteJids: string[]) {
|
||||
remoteJid: string;
|
||||
number: string;
|
||||
jidOptions: string[];
|
||||
lid?: string;
|
||||
}[] = [];
|
||||
|
||||
if (configService.get<Database>('DATABASE').SAVE_DATA.IS_ON_WHATSAPP) {
|
||||
@@ -93,6 +103,7 @@ export async function getOnWhatsappCache(remoteJids: string[]) {
|
||||
remoteJid: item.remoteJid,
|
||||
number: item.remoteJid.split('@')[0],
|
||||
jidOptions: item.jidOptions.split(','),
|
||||
lid: item.lid,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user