feat: provision record all call (#254)

This commit is contained in:
Hoan Luu Huu
2023-06-13 20:03:44 +07:00
committed by GitHub
parent b1fe033c12
commit 96ffce8cd1
25 changed files with 4315 additions and 4998 deletions

View File

@@ -31,9 +31,10 @@ app.get(
for (let i = 0; i < 500; i++) {
const attempted_at = new Date(start.getTime() + i * increment);
const failed = 0 === i % 5;
const call_sid = nanoid();
const call: RecentCall = {
account_sid: req.params.account_sid,
call_sid: nanoid(),
call_sid,
from: "15083084809",
to: "18882349999",
answered: !failed,
@@ -49,6 +50,7 @@ app.get(
direction: 0 === i % 2 ? "inbound" : "outbound",
trunk: 0 === i % 2 ? "twilio" : "user",
trace_id: nanoid(),
recording_url: `http://127.0.0.1:3002/api/Accounts/${req.params.account_sid}/RecentCalls/${call_sid}/record`,
};
data.push(call);
}
@@ -137,6 +139,24 @@ app.get(
}
);
app.get(
"/api/Accounts/:account_sid/RecentCalls/:call_sid/record",
(req: Request, res: Response) => {
/** Sample pcap file from: https://wiki.wireshark.org/SampleCaptures#sip-and-rtp */
const wav: Buffer = fs.readFileSync(
path.resolve(process.cwd(), "server", "example.mp3")
);
res
.status(200)
.set({
"Content-Type": "audio/wav",
"Content-Disposition": "attachment",
})
.send(wav); // server: Buffer => client: Blob
}
);
app.get(
"/api/Accounts/:account_sid/RecentCalls/trace/:trace_id",
(req: Request, res: Response) => {

BIN
server/example.mp3 Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff