29 lines
588 B
TypeScript
29 lines
588 B
TypeScript
|
|
import Whatsapp from "../../models/Whatsapp";
|
|
|
|
const ListWhatsAppsNumber = async (whatsappId: string | number, status: string): Promise<Whatsapp[]> => {
|
|
|
|
const whatsapp = await Whatsapp.findOne({
|
|
raw: true,
|
|
where: { id: whatsappId }
|
|
})
|
|
|
|
if (whatsapp) {
|
|
|
|
const whatsapps = await Whatsapp.findAll({
|
|
raw: true,
|
|
where: { number: whatsapp.number, status: status },
|
|
attributes: ['id', 'number', 'status', 'isDefault']
|
|
});
|
|
|
|
return whatsapps;
|
|
|
|
}
|
|
|
|
return []
|
|
|
|
|
|
};
|
|
|
|
export default ListWhatsAppsNumber;
|