Browse code

kazoo : do not override common properties in payload if they exist

also adds app_name parameter to be sent in "App-Name" field, defaults to NAME at compilation time (kamailio)

Luis Azedo authored on 16/06/2015 19:14:40
Showing 3 changed files
... ...
@@ -13,6 +13,7 @@
13 13
 extern str str_event_message_summary;
14 14
 extern str str_event_dialog;
15 15
 extern str str_event_presence;
16
+extern str kz_app_name;
16 17
 
17 18
 extern str str_username_col;
18 19
 extern str str_domain_col;
... ...
@@ -103,6 +103,8 @@ str kz_db_url = {0,0};
103 103
 str kz_query_timeout_avp = {0,0};
104 104
 pv_spec_t kz_query_timeout_spec;
105 105
 
106
+str kz_app_name = str_init(NAME);
107
+
106 108
 MODULE_VERSION
107 109
 
108 110
 static tr_export_t mod_trans[] = {
... ...
@@ -176,6 +178,7 @@ static param_export_t params[] = {
176 176
     {"consume_messages_on_reconnect", INT_PARAM, &dbk_consume_messages_on_reconnect},
177 177
     {"amqp_query_timeout_avp", STR_PARAM, &kz_query_timeout_avp.s},
178 178
     {"json_escape_char", STR_PARAM, &kz_json_escape_str.s},
179
+    {"app_name", STR_PARAM, &kz_app_name.s},
179 180
     {0, 0, 0}
180 181
 };
181 182
 
... ...
@@ -688,15 +688,19 @@ void kz_amqp_add_payload_common_properties(json_obj_ptr json_obj, char* server_i
688 688
     char node_name[512];
689 689
 
690 690
 
691
-    json_object_object_add(json_obj, BLF_JSON_APP_NAME,
692
-			   json_object_new_string(NAME));
693
-    json_object_object_add(json_obj, BLF_JSON_APP_VERSION,
694
-			   json_object_new_string(VERSION));
695
-    sprintf(node_name, "kamailio@%.*s", dbk_node_hostname.len, dbk_node_hostname.s);
696
-    json_object_object_add(json_obj, BLF_JSON_NODE,
697
-			   json_object_new_string(node_name));
698
-    json_object_object_add(json_obj, BLF_JSON_MSG_ID,
699
-			   json_object_new_string_len(unique->s, unique->len));
691
+	if(kz_json_get_object(json_obj, BLF_JSON_APP_NAME) == NULL)
692
+		json_object_object_add(json_obj, BLF_JSON_APP_NAME, json_object_new_string(kz_app_name.s));
693
+
694
+	if(kz_json_get_object(json_obj, BLF_JSON_APP_VERSION) == NULL)
695
+		json_object_object_add(json_obj, BLF_JSON_APP_VERSION, json_object_new_string(VERSION));
696
+
697
+	if(kz_json_get_object(json_obj, BLF_JSON_NODE) == NULL) {
698
+		sprintf(node_name, "kamailio@%.*s", dbk_node_hostname.len, dbk_node_hostname.s);
699
+		json_object_object_add(json_obj, BLF_JSON_NODE,	json_object_new_string(node_name));	
700
+	}
701
+
702
+	if(kz_json_get_object(json_obj, BLF_JSON_MSG_ID) == NULL)
703
+		json_object_object_add(json_obj, BLF_JSON_MSG_ID, json_object_new_string_len(unique->s, unique->len));
700 704
 
701 705
 }
702 706