nsq: fix MWI NOTIFY with 0 Voice Messages
authorEmmanuel Schmidbauer <emmanuel@getweave.com>
Thu, 12 May 2016 16:07:59 +0000 (12:07 -0400)
committerEmmanuel Schmidbauer <emmanuel@getweave.com>
Thu, 12 May 2016 16:07:59 +0000 (12:07 -0400)
modules/nsq/defs.h
modules/nsq/nsq_pua.c

index 0f479c1..68ab9e7 100644 (file)
@@ -79,6 +79,7 @@
 #define PRESENCE_BODY_BUFFER_SIZE 4096
 
 #define MWI_BODY_VOICE_MESSAGE "Messages-Waiting: %.*s\r\nMessage-Account: %.*s\r\nVoice-Message: %.*s\r\n"
+#define MWI_BODY_NO_VOICE_MESSAGE "Messages-Waiting: %.*s\r\nMessage-Account: %.*s\r\n"
 #define MWI_BODY             "Messages-Waiting: %.*s\r\nMessage-Account: %.*s\r\nVoice-Message: %.*s/%.*s (%.*s/%.*s)\r\n"
 #define PRESENCE_BODY        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" xmlns:c=\"urn:ietf:params:xml:ns:pidf:cipid\" entity=\"%s\"> \
index 005d094..f16b352 100644 (file)
@@ -327,14 +327,17 @@ int nsq_pua_publish_mwi_to_presentity(struct json_object *json_obj) {
                        expires += (int)time(NULL);
        }
 
-       if (mwi_voice_message.len > 0) {
-               sprintf(body, MWI_BODY_VOICE_MESSAGE, mwi_waiting.len, mwi_waiting.s,
-                   mwi_account.len, mwi_account.s, mwi_voice_message.len, mwi_voice_message.s);
-       } else {
+       if (mwi_new.len > 0)
                sprintf(body, MWI_BODY, mwi_waiting.len, mwi_waiting.s,
                    mwi_account.len, mwi_account.s, mwi_new.len, mwi_new.s,
                    mwi_saved.len, mwi_saved.s, mwi_urgent.len, mwi_urgent.s,
                    mwi_urgent_saved.len, mwi_urgent_saved.s);
+       } else if (mwi_voice_message.len > 0) {
+               sprintf(body, MWI_BODY_VOICE_MESSAGE, mwi_waiting.len, mwi_waiting.s,
+                   mwi_account.len, mwi_account.s, mwi_voice_message.len, mwi_voice_message.s);
+       } else {
+               sprintf(body, MWI_BODY_NO_VOICE_MESSAGE, mwi_waiting.len, mwi_waiting.s,
+                   mwi_account.len, mwi_account.s);
        }
 
        mwi_body.s = body;