]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add attr lookup to user_data
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Nov 2008 22:42:49 +0000 (22:42 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Nov 2008 22:42:49 +0000 (22:42 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10388 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_commands/mod_commands.c

index 2743a635e199289d3b08fef7e444d9aac12ef800..5ea53c3ff76193823c783ab6c066aa6faeab5343 100644 (file)
@@ -112,6 +112,12 @@ SWITCH_STANDARD_API(user_data_function)
        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "key", key);
 
        if (key && type && switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, params) == SWITCH_STATUS_SUCCESS) {
+               if (!strcmp(type, "attr")) {
+                       const char *attr = switch_xml_attr_soft(x_user, key);
+                       stream->write_function(stream, "%s", attr);
+                       goto end;
+               }
+
                if (!strcmp(type, "var")) {
                        container = "variables";
                        elem = "variable";
@@ -3080,7 +3086,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "find_user_xml", "find a user", find_user_function, "<key> <user> <domain>");
        SWITCH_ADD_API(commands_api_interface, "user_exists", "find a user", user_exists_function, "<key> <user> <domain>");
        SWITCH_ADD_API(commands_api_interface, "xml_locate", "find some xml", xml_locate_function, "[root | <section> <tag> <tag_attr_name> <tag_attr_val>]");
-       SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "<user>@<domain> [var|param] <name>");
+       SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "<user>@<domain> [var|param|attr] <name>");
        SWITCH_ADD_API(commands_api_interface, "url_encode", "url encode a string", url_encode_function, "<string>");
        SWITCH_ADD_API(commands_api_interface, "url_decode", "url decode a string", url_decode_function, "<string>");
        SWITCH_ADD_API(commands_api_interface, "module_exists", "check if module exists", module_exists_function, "<module>");