(remoteJids: string[])
| 180 | } |
| 181 | |
| 182 | export 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 | } |
no test coverage detected