diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c
index a42bbadcec..8f2bb0759a 100644
--- a/src/mod/endpoints/mod_sofia/sofia_presence.c
+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c
@@ -537,7 +537,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
if (switch_strlen_zero(state)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", SOFIA_CHAT_PROTO);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_HANGUP");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "terminated");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "resubscribe");
} else {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_RING");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", uuid);
@@ -667,6 +667,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
const char *state = switch_str_nil(switch_event_get_header(helper->event, "channel-state"));
const char *event_status = switch_str_nil(switch_event_get_header(helper->event, "status"));
const char *astate = switch_str_nil(switch_event_get_header(helper->event, "astate"));
+ char *answer_state = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
const char *dft_state;
SWITCH_STANDARD_STREAM(stream);
@@ -682,6 +683,20 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
if (!strcasecmp(state, "cs_execute") && !strstr(event_status, "hold")) {
goto end;
}
+ printf("WTF %s, %s, %s, %s\n", state, event_status, answer_state, astate);
+
+ if (!strcasecmp(event_status, "Registered")) {
+ answer_state = "resubscribe";
+ }
+
+ stream.write_function(&stream,
+ "\n"
+ "\n",
+ switch_str_nil(switch_event_get_header(helper->event, "event_count")),
+ !strcasecmp(answer_state, "resubscribe") ? "partial" : "full", clean_id);
+
+ if (strcasecmp(answer_state, "resubscribe")) {
if (!strcasecmp(state, "cs_hangup")) {
astate = "terminated";
@@ -707,20 +722,43 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
astate = "confirmed";
}
}
+ stream.write_function(&stream, "\n");
+
+ } else {
+ printf("resubscribe\n");
+ }
+
+ stream.write_function(&stream, "\n");
- stream.write_function(&stream, "\n\n");
pl = stream.data;
ct = "application/dialog-info+xml";
-
+ printf("%s\n", pl);
if (astate && uuid && helper->stream.data) {
stream.write_function(&helper->stream, "update sip_dialogs set state='%s' where uuid='%s';\n", astate, uuid);
}