/twilio-token returns null when twilio account is not connected => device won't try to connect

This commit is contained in:
m5r 2022-06-27 13:12:49 +02:00
parent 68c65a945a
commit fad2dc06e1

View File

@ -6,13 +6,15 @@ import { decrypt, encrypt } from "~/utils/encryption";
import db from "~/utils/db.server";
import { commitSession } from "~/utils/session.server";
import getTwilioClient from "~/utils/twilio.server";
import logger from "~/utils/logger.server";
export type TwilioTokenLoaderData = string;
const loader: LoaderFunction = async ({ request }) => {
const { user, twilio } = await requireLoggedIn(request);
if (!twilio) {
throw new Error("unreachable");
logger.warn("Twilio account is not connected");
return null;
}
const twilioAccount = await db.twilioAccount.findUnique({ where: { accountSid: twilio.accountSid } });