feat support multi speech credential with diff labels and same vendor (#218)

* feat support multi speech credential with diff labels and same vendor

* fix review comment

* wip

* fix review comments

* update verb spec version
This commit is contained in:
Hoan Luu Huu authored and GitHub committed 2023-08-15 08:53:16 -04:00
1 parent de7b74f898
commit 7351f0ad68
8 files changed
+68 -33

No files matched your search

+11
View File
@@ -207,6 +207,7 @@ router.post('/', async(req, res) => {
use_for_stt,
use_for_tts,
vendor,
label
} = req.body;
const account_sid = req.user.account_sid || req.body.account_sid;
const service_provider_sid = req.user.service_provider_sid ||
@@ -221,11 +222,21 @@ router.post('/', async(req, res) => {
}
}
// Check if vendor and label is already used for account or SP
if (label) {
const existingSpeech = await SpeechCredential.isAvailableVendorAndLabel(
service_provider_sid, account_sid, vendor, label);
if (existingSpeech.length > 0) {
throw new DbErrorUnprocessableRequest(`Label ${label} is already in use for another speech credential`);
}
}
const encrypted_credential = encryptCredential(req.body);
const uuid = await SpeechCredential.make({
account_sid,
service_provider_sid,
vendor,
label,
use_for_tts,
use_for_stt,
credential: encrypted_credential