fix /twilio/authorize

This commit is contained in:
m5r 2022-05-22 01:18:06 +02:00
parent 1f37eb45d5
commit c1c3fa06a3

View File

@ -24,9 +24,18 @@ export const loader: LoaderFunction = async ({ request }) => {
const twilioMainAccount = await twilioClient.api.accounts(twilioMainAccountSid).fetch(); const twilioMainAccount = await twilioClient.api.accounts(twilioMainAccountSid).fetch();
console.log("twilioSubAccount", twilioSubAccount); console.log("twilioSubAccount", twilioSubAccount);
console.log("twilioAccount", twilioMainAccount); console.log("twilioAccount", twilioMainAccount);
const twilioAccount = await db.twilioAccount.update({ const twilioAccount = await db.twilioAccount.upsert({
where: { organizationId: organization.id }, where: { organizationId: organization.id },
data: { create: {
organization: {
connect: { id: organization.id },
},
subAccountSid: twilioSubAccount.sid,
subAccountAuthToken: encrypt(twilioSubAccount.authToken),
accountSid: twilioMainAccount.sid,
accountAuthToken: encrypt(twilioMainAccount.authToken),
},
update: {
subAccountSid: twilioSubAccount.sid, subAccountSid: twilioSubAccount.sid,
subAccountAuthToken: encrypt(twilioSubAccount.authToken), subAccountAuthToken: encrypt(twilioSubAccount.authToken),
accountSid: twilioMainAccount.sid, accountSid: twilioMainAccount.sid,