Module: kamailio Branch: 5.5 Commit: b0125b66116468b1e5d0dd2ee4eb0eebb4e7ecb4 URL: https://github.com/kamailio/kamailio/commit/b0125b66116468b1e5d0dd2ee4eb0eeb...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2021-09-09T10:33:35+02:00
presence: skip body operations on empty string
(cherry picked from commit c849070371740c01f9f13a889c610de9132349f3)
---
Modified: src/modules/presence/notify.c Modified: src/modules/presence/presence_dmq.c Modified: src/modules/presence/presentity.c
---
Diff: https://github.com/kamailio/kamailio/commit/b0125b66116468b1e5d0dd2ee4eb0eeb... Patch: https://github.com/kamailio/kamailio/commit/b0125b66116468b1e5d0dd2ee4eb0eeb...
---
diff --git a/src/modules/presence/notify.c b/src/modules/presence/notify.c index 87ed58cff4..cf52c21c22 100644 --- a/src/modules/presence/notify.c +++ b/src/modules/presence/notify.c @@ -1700,7 +1700,8 @@ int send_notify_request( }
/* build extra headers */ - if(build_str_hdr(subs, notify_body ? 1 : 0, &str_hdr) < 0) { + if(build_str_hdr(subs, (notify_body && notify_body->len>0) ? 1 : 0, + &str_hdr) < 0) { LM_ERR("while building headers\n"); goto error; } diff --git a/src/modules/presence/presence_dmq.c b/src/modules/presence/presence_dmq.c index 8dd7c99fe8..83a88f1aa1 100644 --- a/src/modules/presence/presence_dmq.c +++ b/src/modules/presence/presence_dmq.c @@ -303,6 +303,9 @@ int pres_dmq_handle_msg( } else if(strcmp(it->string, "body") == 0) { p_body.s = it->valuestring; p_body.len = strlen(it->valuestring); + if(p_body.len==0) { + p_body.s = NULL; + } } else { LM_ERR("unrecognized field in json object\n"); goto invalid; diff --git a/src/modules/presence/presentity.c b/src/modules/presence/presentity.c index bc17bf1074..a7629a4e92 100644 --- a/src/modules/presence/presentity.c +++ b/src/modules/presence/presentity.c @@ -737,6 +737,7 @@ static int ps_db_update_presentity(sip_msg_t *msg, presentity_t *presentity, result_cols[rez_ruid_col = n_result_cols++] = &str_ruid_col;
if(new_t) { + /* new_t!=0 */ LM_DBG("new presentity with etag %.*s\n", presentity->etag.len, presentity->etag.s);
@@ -888,6 +889,7 @@ static int ps_db_update_presentity(sip_msg_t *msg, presentity_t *presentity, *sent_reply = 1; goto send_notify; } else { + /* new_t==0 */ LM_DBG("updating existing presentity with etag %.*s\n", presentity->etag.len, presentity->etag.s);
@@ -1206,7 +1208,7 @@ static int ps_db_update_presentity(sip_msg_t *msg, presentity_t *presentity, update_vals[n_update_cols].val.int_val = presentity->priority; n_update_cols++;
- if(body && body->s) { + if(body && body->s && body->len>0) { update_keys[n_update_cols] = &str_body_col; update_vals[n_update_cols].type = DB1_BLOB; update_vals[n_update_cols].nul = 0; @@ -1748,7 +1750,7 @@ static int ps_cache_update_presentity(sip_msg_t *msg, presentity_t *presentity, ptc.expires = presentity->expires + (int)time(NULL); ptc.received_time = presentity->received_time; ptc.priority = presentity->priority; - if(body && body->s) { + if(body && body->s && body->len>0) { ptc.body = *body; } if(presentity->sender) {