MCPcopy Create free account
hub / github.com/evolution-foundation/evolution-api / getOnWhatsappCache

Function getOnWhatsappCache

src/utils/onWhatsappCache.ts:182–211  ·  view source on GitHub ↗
(remoteJids: string[])

Source from the content-addressed store, hash-verified

180}
181
182export async function getOnWhatsappCache(remoteJids: string[]) {
183 let results: {
184 remoteJid: string;
185 number: string;
186 jidOptions: string[];
187 lid?: string;
188 }[] = [];
189
190 if (configService.get<Database>('DATABASE').SAVE_DATA.IS_ON_WHATSAPP) {
191 const remoteJidsWithoutPlus = remoteJids.map((remoteJid) => getAvailableNumbers(remoteJid)).flat();
192
193 const onWhatsappCache = await prismaRepository.isOnWhatsapp.findMany({
194 where: {
195 OR: remoteJidsWithoutPlus.map((remoteJid) => ({ jidOptions: { contains: remoteJid } })),
196 updatedAt: {
197 gte: dayjs().subtract(configService.get<Database>('DATABASE').SAVE_DATA.IS_ON_WHATSAPP_DAYS, 'days').toDate(),
198 },
199 },
200 });
201
202 results = onWhatsappCache.map((item) => ({
203 remoteJid: item.remoteJid,
204 number: item.remoteJid.split('@')[0],
205 jidOptions: item.jidOptions.split(','),
206 lid: item.lid,
207 }));
208 }
209
210 return results;
211}

Callers 1

whatsappNumberMethod · 0.90

Calls 2

getAvailableNumbersFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected