2021-07-31 15:57:43 +00:00
|
|
|
import { BlitzApiRequest, BlitzApiResponse } from "blitz";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-07-31 15:57:43 +00:00
|
|
|
import db from "db";
|
2021-08-01 07:40:18 +00:00
|
|
|
import twilio from "twilio";
|
2021-10-15 23:33:39 +00:00
|
|
|
import setTwilioWebhooks from "../settings/api/queue/set-twilio-webhooks";
|
|
|
|
import backup from "../../db/backup";
|
|
|
|
import { sendEmail } from "../../integrations/aws-ses";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default async function ddd(req: BlitzApiRequest, res: BlitzApiResponse) {
|
2021-08-01 14:01:51 +00:00
|
|
|
/*await Promise.all([
|
2021-07-31 14:33:18 +00:00
|
|
|
db.message.deleteMany(),
|
|
|
|
db.phoneCall.deleteMany(),
|
|
|
|
db.phoneNumber.deleteMany(),
|
2021-07-31 15:57:43 +00:00
|
|
|
]);
|
2021-08-01 14:01:51 +00:00
|
|
|
await db.customer.deleteMany();
|
|
|
|
await db.user.deleteMany();*/
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-01 07:40:18 +00:00
|
|
|
const accountSid = "ACa886d066be0832990d1cf43fb1d53362";
|
|
|
|
const authToken = "8696a59a64b94bb4eba3548ed815953b";
|
|
|
|
/*const ddd = await twilio(accountSid, authToken)
|
|
|
|
.lookups
|
|
|
|
.v1
|
|
|
|
// .phoneNumbers("+33613370787")
|
|
|
|
.phoneNumbers("+33476982071")
|
|
|
|
.fetch();*/
|
2021-08-01 10:36:32 +00:00
|
|
|
/*try {
|
2021-08-01 07:40:18 +00:00
|
|
|
await twilio(accountSid, authToken).messages.create({
|
|
|
|
body: "content",
|
|
|
|
to: "+213744123789",
|
|
|
|
from: "+33757592025",
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error.code);
|
|
|
|
console.log(error.moreInfo);
|
|
|
|
console.log(error.details);
|
|
|
|
// console.log(JSON.stringify(Object.keys(error)));
|
2021-08-01 10:36:32 +00:00
|
|
|
}*/
|
2021-08-01 11:21:49 +00:00
|
|
|
/*const ddd = await twilio(accountSid, authToken).messages.create({
|
2021-08-01 16:28:47 +00:00
|
|
|
body: "cccccasdasd",
|
2021-08-01 10:36:32 +00:00
|
|
|
to: "+33757592025",
|
|
|
|
from: "+33757592722",
|
2021-08-01 11:21:49 +00:00
|
|
|
});*/
|
2021-08-01 14:01:51 +00:00
|
|
|
/*const [messagesSent, messagesReceived] = await Promise.all([
|
|
|
|
twilio(accountSid, authToken).messages.list({
|
|
|
|
from: "+33757592025",
|
|
|
|
}),
|
|
|
|
twilio(accountSid, authToken).messages.list({
|
|
|
|
to: "+33757592025",
|
|
|
|
}),
|
|
|
|
]);
|
|
|
|
|
|
|
|
console.log("messagesReceived", messagesReceived.sort((a, b) => a.dateCreated.getTime() - b.dateCreated.getTime()));
|
|
|
|
// console.log("messagesReceived", messagesReceived);*/
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-30 11:24:05 +00:00
|
|
|
/*setTwilioWebhooks.enqueue({
|
|
|
|
phoneNumberId: "PNb77c9690c394368bdbaf20ea6fe5e9fc",
|
|
|
|
organizationId: "95267d60-3d35-4c36-9905-8543ecb4f174",
|
|
|
|
});*/
|
2021-10-15 23:33:39 +00:00
|
|
|
/*try {
|
|
|
|
const before = Date.now();
|
|
|
|
await backup("daily");
|
|
|
|
console.log(`took ${Date.now() - before}ms`);
|
|
|
|
} catch (error) {
|
|
|
|
console.error("dddd error", error);
|
|
|
|
res.status(500).end();
|
|
|
|
}*/
|
2021-08-30 11:24:05 +00:00
|
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
res.status(200).end();
|
|
|
|
// }, 1000 * 60 * 5);
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|