mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	ARI: Add mailboxes resource for controlling and polling external MWI
Adds the following AMI commands:
PUT mailboxes/mailboxName
    modifies mailbox state and implicitly creates new mailboxes
GET mailboxes/mailboxName
    retrieves a JSON representation of a single mailbox if it exists
GET mailboxes
    retrieves a JSON array of all mailboxes
DELETE mailbox/mailboxName
    deletes a mailbox
Note that res_mwi_external must be loaded for these functions to
actually do anything.
Review: https://reviewboard.asterisk.org/r/3117/
........
Merged revisions 405553 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405554 65c4cc65-6c06-0410-ace0-fbb531ad65f3
			
			
This commit is contained in:
		| @@ -1419,6 +1419,76 @@ ari_validator ast_ari_validate_device_state_fn(void) | ||||
| 	return ast_ari_validate_device_state; | ||||
| } | ||||
|  | ||||
| int ast_ari_validate_mailbox(struct ast_json *json) | ||||
| { | ||||
| 	int res = 1; | ||||
| 	struct ast_json_iter *iter; | ||||
| 	int has_name = 0; | ||||
| 	int has_new_messages = 0; | ||||
| 	int has_old_messages = 0; | ||||
|  | ||||
| 	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) { | ||||
| 		if (strcmp("name", ast_json_object_iter_key(iter)) == 0) { | ||||
| 			int prop_is_valid; | ||||
| 			has_name = 1; | ||||
| 			prop_is_valid = ast_ari_validate_string( | ||||
| 				ast_json_object_iter_value(iter)); | ||||
| 			if (!prop_is_valid) { | ||||
| 				ast_log(LOG_ERROR, "ARI Mailbox field name failed validation\n"); | ||||
| 				res = 0; | ||||
| 			} | ||||
| 		} else | ||||
| 		if (strcmp("new_messages", ast_json_object_iter_key(iter)) == 0) { | ||||
| 			int prop_is_valid; | ||||
| 			has_new_messages = 1; | ||||
| 			prop_is_valid = ast_ari_validate_int( | ||||
| 				ast_json_object_iter_value(iter)); | ||||
| 			if (!prop_is_valid) { | ||||
| 				ast_log(LOG_ERROR, "ARI Mailbox field new_messages failed validation\n"); | ||||
| 				res = 0; | ||||
| 			} | ||||
| 		} else | ||||
| 		if (strcmp("old_messages", ast_json_object_iter_key(iter)) == 0) { | ||||
| 			int prop_is_valid; | ||||
| 			has_old_messages = 1; | ||||
| 			prop_is_valid = ast_ari_validate_int( | ||||
| 				ast_json_object_iter_value(iter)); | ||||
| 			if (!prop_is_valid) { | ||||
| 				ast_log(LOG_ERROR, "ARI Mailbox field old_messages failed validation\n"); | ||||
| 				res = 0; | ||||
| 			} | ||||
| 		} else | ||||
| 		{ | ||||
| 			ast_log(LOG_ERROR, | ||||
| 				"ARI Mailbox has undocumented field %s\n", | ||||
| 				ast_json_object_iter_key(iter)); | ||||
| 			res = 0; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (!has_name) { | ||||
| 		ast_log(LOG_ERROR, "ARI Mailbox missing required field name\n"); | ||||
| 		res = 0; | ||||
| 	} | ||||
|  | ||||
| 	if (!has_new_messages) { | ||||
| 		ast_log(LOG_ERROR, "ARI Mailbox missing required field new_messages\n"); | ||||
| 		res = 0; | ||||
| 	} | ||||
|  | ||||
| 	if (!has_old_messages) { | ||||
| 		ast_log(LOG_ERROR, "ARI Mailbox missing required field old_messages\n"); | ||||
| 		res = 0; | ||||
| 	} | ||||
|  | ||||
| 	return res; | ||||
| } | ||||
|  | ||||
| ari_validator ast_ari_validate_mailbox_fn(void) | ||||
| { | ||||
| 	return ast_ari_validate_mailbox; | ||||
| } | ||||
|  | ||||
| int ast_ari_validate_application_replaced(struct ast_json *json) | ||||
| { | ||||
| 	int res = 1; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user