mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-03 11:11:05 +00:00
ARI recordings: Issue HTTP failures for recording requests with file conflicts
If a file already exists in the recordings directory with the same name as what we would record, issue a 422 instead of relying on the internal failure and issuing success. (closes issue ASTERISK-22623) Reported by: Joshua Colp Review: https://reviewboard.asterisk.org/r/2922/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@401973 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3288,6 +3288,136 @@ ari_validator ast_ari_validate_playback_started_fn(void)
|
||||
return ast_ari_validate_playback_started;
|
||||
}
|
||||
|
||||
int ast_ari_validate_recording_failed(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
struct ast_json_iter *iter;
|
||||
int has_cause = 0;
|
||||
int has_recording = 0;
|
||||
|
||||
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
|
||||
if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_cause = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingFailed field cause failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_recording = 1;
|
||||
prop_is_valid = ast_ari_validate_live_recording(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingFailed field recording failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ast_log(LOG_ERROR,
|
||||
"ARI RecordingFailed has undocumented field %s\n",
|
||||
ast_json_object_iter_key(iter));
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_cause) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingFailed missing required field cause\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_recording) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingFailed missing required field recording\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ari_validator ast_ari_validate_recording_failed_fn(void)
|
||||
{
|
||||
return ast_ari_validate_recording_failed;
|
||||
}
|
||||
|
||||
int ast_ari_validate_recording_finished(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
struct ast_json_iter *iter;
|
||||
int has_recording = 0;
|
||||
|
||||
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
|
||||
if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_recording = 1;
|
||||
prop_is_valid = ast_ari_validate_live_recording(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingFinished field recording failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ast_log(LOG_ERROR,
|
||||
"ARI RecordingFinished has undocumented field %s\n",
|
||||
ast_json_object_iter_key(iter));
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_recording) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingFinished missing required field recording\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ari_validator ast_ari_validate_recording_finished_fn(void)
|
||||
{
|
||||
return ast_ari_validate_recording_finished;
|
||||
}
|
||||
|
||||
int ast_ari_validate_recording_started(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
struct ast_json_iter *iter;
|
||||
int has_recording = 0;
|
||||
|
||||
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
|
||||
if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_recording = 1;
|
||||
prop_is_valid = ast_ari_validate_live_recording(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingStarted field recording failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ast_log(LOG_ERROR,
|
||||
"ARI RecordingStarted has undocumented field %s\n",
|
||||
ast_json_object_iter_key(iter));
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_recording) {
|
||||
ast_log(LOG_ERROR, "ARI RecordingStarted missing required field recording\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ari_validator ast_ari_validate_recording_started_fn(void)
|
||||
{
|
||||
return ast_ari_validate_recording_started;
|
||||
}
|
||||
|
||||
int ast_ari_validate_stasis_end(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
|
Reference in New Issue
Block a user