Skip to content

Commit

Permalink
kazoo: only create tags if not empty
Browse files Browse the repository at this point in the history
to-tag and from-tag are created empty if not supplied in amp payload
this patch formats the dialog message to include the tags only if they are supplied in amp payload

(cherry picked from commit deb0e81)
  • Loading branch information
lazedo committed Mar 9, 2015
1 parent 7140f86 commit 4e1a100
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/kazoo/defs.h
Expand Up @@ -69,14 +69,17 @@

#define DIALOGINFO_EMPTY_BODY "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"1\" state=\"full\" entity=\"%.*s\"> \
<dialog direction=\"initiator\">\
<dialog call-id=\"76001e23e09704ea9e1257ebea85e1f3\" direction=\"initiator\">\
<state>terminated</state>\
</dialog>\
</dialog-info>"

#define LOCAL_TAG "local-tag=\"%.*s\""
#define REMOTE_TAG "remote-tag=\"%.*s\""

#define DIALOGINFO_BODY "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"1\" state=\"full\" entity=\"%.*s\">\
<dialog id=\"%.*s\" call-id=\"%.*s\" local-tag=\"%.*s\" remote-tag=\"%.*s\" direction=\"%.*s\">\
<dialog id=\"%.*s\" call-id=\"%.*s\" %.*s %.*s direction=\"%.*s\">\
<state>%.*s</state>\
<local>\
<identity display=\"%.*s\">%.*s</identity>\
Expand All @@ -91,7 +94,7 @@

#define DIALOGINFO_BODY_2 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"1\" state=\"full\" entity=\"%.*s\">\
<dialog id=\"%.*s\" call-id=\"%.*s\" local-tag=\"%.*s\" remote-tag=\"%.*s\" direction=\"%.*s\">\
<dialog id=\"%.*s\" call-id=\"%.*s\" %.*s %.*s direction=\"%.*s\">\
<state>%.*s</state>\
<local>\
<identity display=\"%.*s\">%.*s</identity>\
Expand Down
12 changes: 12 additions & 0 deletions modules/kazoo/kz_pua.c
Expand Up @@ -320,6 +320,8 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
int expires = 0;
str event = str_init("dialog");
int reset = 0;
char to_tag_buffer[100];
char from_tag_buffer[100];

char *body = (char *)pkg_malloc(DIALOGINFO_BODY_BUFFER_SIZE);
if(body == NULL) {
Expand Down Expand Up @@ -375,6 +377,16 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
if(!to_uri.len)
to_uri = to;

if(fromtag.len > 0) {
fromtag.len = sprintf(from_tag_buffer, LOCAL_TAG, fromtag.len, fromtag.s);
fromtag.s = from_tag_buffer;
}

if(totag.len > 0) {
totag.len = sprintf(to_tag_buffer, REMOTE_TAG, totag.len, totag.s);
totag.s = to_tag_buffer;
}

if(callid.len) {

if(dbk_include_entity) {
Expand Down

0 comments on commit 4e1a100

Please sign in to comment.