Move in progress apps temporarily
This commit is contained in:
parent
ba04aa108c
commit
6eaaf8e9be
360 changed files with 6171 additions and 55 deletions
|
|
@ -1,41 +0,0 @@
|
|||
import Twilio from "twilio";
|
||||
import config from "config";
|
||||
import { withDb, AppDatabase } from "../db";
|
||||
|
||||
interface VoiceLineDeleteTaskOptions {
|
||||
voiceLineId: string;
|
||||
providerId: string;
|
||||
providerLineSid: string;
|
||||
}
|
||||
|
||||
const voiceLineDeleteTask = async (
|
||||
payload: VoiceLineDeleteTaskOptions
|
||||
): Promise<void> =>
|
||||
withDb(async (db: AppDatabase) => {
|
||||
const { voiceLineId, providerId, providerLineSid } = payload;
|
||||
const provider = await db.voiceProviders.findById({ id: providerId });
|
||||
if (!provider) return;
|
||||
|
||||
const { accountSid, apiKeySid, apiKeySecret } = provider.credentials;
|
||||
if (!accountSid || !apiKeySid || !apiKeySecret)
|
||||
throw new Error(
|
||||
`twilio provider ${provider.name} does not have credentials`
|
||||
);
|
||||
|
||||
const client = Twilio(apiKeySid, apiKeySecret, {
|
||||
accountSid,
|
||||
});
|
||||
|
||||
const number = await client.incomingPhoneNumbers(providerLineSid).fetch();
|
||||
if (
|
||||
number &&
|
||||
number.voiceUrl ===
|
||||
`${config.frontend.url}/api/v1/voice/twilio/record/${voiceLineId}`
|
||||
)
|
||||
await client.incomingPhoneNumbers(providerLineSid).update({
|
||||
voiceUrl: "",
|
||||
voiceMethod: "POST",
|
||||
});
|
||||
});
|
||||
|
||||
export default voiceLineDeleteTask;
|
||||
Loading…
Add table
Add a link
Reference in a new issue