improved dlr
This commit is contained in:
parent
0dfdfdc305
commit
3e3b9b2b2b
|
@ -78,11 +78,12 @@ done:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mmsbox_send_report(Octstr *from, char *report_type,
|
static int mmsbox_send_report(Octstr *from, char *report_type,
|
||||||
Octstr *dlr_url, Octstr *status,
|
Octstr *dlr_url, Octstr *status,
|
||||||
Octstr *msgid, Octstr *mmc_id, Octstr *mmc_gid,
|
Octstr *msgid, Octstr *orig_msgid,
|
||||||
Octstr *orig_transid, Octstr *uaprof,
|
Octstr *mmc_id, Octstr *mmc_gid,
|
||||||
time_t uaprof_tstamp)
|
Octstr *orig_transid, Octstr *uaprof,
|
||||||
|
time_t uaprof_tstamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
Octstr *url = NULL;
|
Octstr *url = NULL;
|
||||||
|
@ -117,6 +118,10 @@ int mmsbox_send_report(Octstr *from, char *report_type,
|
||||||
octstr_get_cstr(xtransid ? xtransid : orig_transid));
|
octstr_get_cstr(xtransid ? xtransid : orig_transid));
|
||||||
if (msgid)
|
if (msgid)
|
||||||
http_header_add(rh, "X-Mbuni-Message-ID", octstr_get_cstr(msgid));
|
http_header_add(rh, "X-Mbuni-Message-ID", octstr_get_cstr(msgid));
|
||||||
|
|
||||||
|
if (orig_msgid)
|
||||||
|
http_header_add(rh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(orig_msgid));
|
||||||
|
|
||||||
if (uaprof) {
|
if (uaprof) {
|
||||||
Octstr *sx = date_format_http(uaprof_tstamp);
|
Octstr *sx = date_format_http(uaprof_tstamp);
|
||||||
http_header_add(rh, "X-Mbuni-UAProf", octstr_get_cstr(uaprof));
|
http_header_add(rh, "X-Mbuni-UAProf", octstr_get_cstr(uaprof));
|
||||||
|
@ -159,6 +164,8 @@ static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype)
|
||||||
octstr_delete(newmsgid, 0, x+1);
|
octstr_delete(newmsgid, 0, x+1);
|
||||||
|
|
||||||
mms_replace_header_value(m, "Message-ID", octstr_get_cstr(newmsgid));
|
mms_replace_header_value(m, "Message-ID", octstr_get_cstr(newmsgid));
|
||||||
|
/* Add it back as original. */
|
||||||
|
mms_replace_header_value(m, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value));
|
||||||
|
|
||||||
mms_dlr_url_remove(value, "delivery-report", mmc->group_id);
|
mms_dlr_url_remove(value, "delivery-report", mmc->group_id);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +304,7 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
||||||
octstr_get_cstr(from), octstr_get_cstr(value), octstr_get_cstr(desc),
|
octstr_get_cstr(from), octstr_get_cstr(value), octstr_get_cstr(desc),
|
||||||
octstr_get_cstr(h->m->id));
|
octstr_get_cstr(h->m->id));
|
||||||
mmsbox_send_report(from, "delivery-report", NULL,
|
mmsbox_send_report(from, "delivery-report", NULL,
|
||||||
value, msgid, h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
|
value, msgid, NULL, h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
|
||||||
|
|
||||||
mms_log("DeliveryReport",
|
mms_log("DeliveryReport",
|
||||||
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
||||||
|
@ -336,8 +343,8 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
||||||
msgid = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
|
msgid = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
|
||||||
|
|
||||||
mmsbox_send_report(from,
|
mmsbox_send_report(from,
|
||||||
"read-report", NULL, value, msgid,
|
"read-report", NULL, value, msgid, NULL,
|
||||||
h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
|
h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
|
||||||
|
|
||||||
octstr_destroy(value);
|
octstr_destroy(value);
|
||||||
mms_log("ReadReport",
|
mms_log("ReadReport",
|
||||||
|
@ -380,6 +387,20 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
||||||
return MM7_SOAP_STATUS_OK(status) ? 0 : -1;
|
return MM7_SOAP_STATUS_OK(status) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper func to avoid code duplication below. */
|
||||||
|
static void handle_report_dispatch(MmscGrp *m, Octstr *hfrom, char *rtype, List *mh, Octstr *status_hdr)
|
||||||
|
{
|
||||||
|
Octstr *value = http_header_value(mh, status_hdr);
|
||||||
|
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
||||||
|
Octstr *value3 = http_header_value(mh, octstr_imm("X-Mbuni-Orig-Message-ID"));
|
||||||
|
|
||||||
|
mmsbox_send_report(hfrom, rtype, NULL, value, value2, value3, m->id,
|
||||||
|
m->group_id, NULL, NULL, -1);
|
||||||
|
octstr_destroy(value);
|
||||||
|
octstr_destroy(value2);
|
||||||
|
octstr_destroy(value3);
|
||||||
|
}
|
||||||
|
|
||||||
static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
||||||
{
|
{
|
||||||
MmsMsg *m = NULL;
|
MmsMsg *m = NULL;
|
||||||
|
@ -524,14 +545,8 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
||||||
hstatus = HTTP_NO_CONTENT;
|
hstatus = HTTP_NO_CONTENT;
|
||||||
} else
|
} else
|
||||||
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
||||||
} else {
|
} else
|
||||||
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Status"));
|
handle_report_dispatch(h->m, hfrom, "delivery-report", mh, octstr_imm("X-Mms-Status"));
|
||||||
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
|
||||||
mmsbox_send_report(hfrom, "delivery-report", NULL, value, value2, h->m->id, h->m->group_id, NULL, NULL, -1);
|
|
||||||
|
|
||||||
octstr_destroy(value);
|
|
||||||
octstr_destroy(value2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MMS_MSGTYPE_READ_ORIG_IND:
|
case MMS_MSGTYPE_READ_ORIG_IND:
|
||||||
|
@ -554,16 +569,9 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
||||||
hstatus = HTTP_NO_CONTENT;
|
hstatus = HTTP_NO_CONTENT;
|
||||||
} else
|
} else
|
||||||
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
||||||
} else {
|
} else
|
||||||
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Read-Status"));
|
handle_report_dispatch(h->m, hfrom, "read-report", mh, octstr_imm("X-Mms-Read-Status"));
|
||||||
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
|
||||||
mmsbox_send_report(hfrom, "read-report", NULL, value, value2, h->m->id,
|
|
||||||
h->m->group_id, NULL, NULL, -1);
|
|
||||||
|
|
||||||
|
|
||||||
octstr_destroy(value);
|
|
||||||
octstr_destroy(value2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,16 +770,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
||||||
hstatus = HTTP_OK;
|
hstatus = HTTP_OK;
|
||||||
} else
|
} else
|
||||||
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
||||||
} else {
|
} else
|
||||||
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Status"));
|
handle_report_dispatch(h->m, hfrom, "delivery-report", mh, octstr_imm("X-Mms-Status"));
|
||||||
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
|
||||||
|
|
||||||
mmsbox_send_report(hfrom, "delivery-report", NULL, value, value2,
|
|
||||||
h->m->id, h->m->group_id, NULL, NULL, -1);
|
|
||||||
|
|
||||||
octstr_destroy(value);
|
|
||||||
octstr_destroy(value2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MMS_MSGTYPE_READ_ORIG_IND:
|
case MMS_MSGTYPE_READ_ORIG_IND:
|
||||||
|
@ -795,15 +795,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
||||||
hstatus = HTTP_NO_CONTENT;
|
hstatus = HTTP_NO_CONTENT;
|
||||||
} else
|
} else
|
||||||
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
||||||
} else {
|
} else
|
||||||
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Read-Status"));
|
handle_report_dispatch(h->m, hfrom, "read-report", mh, octstr_imm("X-Mms-Read-Status"));
|
||||||
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
|
||||||
mmsbox_send_report(hfrom, "read-report", NULL, value, value2, h->m->id,
|
|
||||||
h->m->group_id, NULL, NULL, -1);
|
|
||||||
|
|
||||||
octstr_destroy(value);
|
|
||||||
octstr_destroy(value2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1354,13 +1347,14 @@ static int sendMsg(MmsEnvelope *e)
|
||||||
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
||||||
to->process = 0;
|
to->process = 0;
|
||||||
mmsbox_send_report(to->rcpt, "delivery-report", e->url1,
|
mmsbox_send_report(to->rcpt, "delivery-report", e->url1,
|
||||||
octstr_imm("Sent"), new_msgid, mmc->id, mmc->group_id, otransid, NULL, -1);
|
octstr_imm("Sent"), new_msgid, NULL,
|
||||||
|
mmc->id, mmc->group_id, otransid, NULL, -1);
|
||||||
} else if (res == MMS_SEND_ERROR_FATAL && mmc)
|
} else if (res == MMS_SEND_ERROR_FATAL && mmc)
|
||||||
mmsbox_send_report(to->rcpt, "delivery-report",
|
mmsbox_send_report(to->rcpt, "delivery-report",
|
||||||
e->url1,
|
e->url1,
|
||||||
(e->expiryt != 0 && e->expiryt < tnow) ?
|
(e->expiryt != 0 && e->expiryt < tnow) ?
|
||||||
octstr_imm("Expired") : octstr_imm("Rejected"),
|
octstr_imm("Expired") : octstr_imm("Rejected"),
|
||||||
e->msgId, mmc->id, mmc->group_id, otransid, NULL, -1);
|
e->msgId, NULL, mmc->id, mmc->group_id, otransid, NULL, -1);
|
||||||
if (res == MMS_SEND_ERROR_FATAL)
|
if (res == MMS_SEND_ERROR_FATAL)
|
||||||
to->process = 0; /* No more attempts. */
|
to->process = 0; /* No more attempts. */
|
||||||
|
|
||||||
|
@ -1392,9 +1386,9 @@ static int sendMsg(MmsEnvelope *e)
|
||||||
else
|
else
|
||||||
mms_error_ex("MT", 0,
|
mms_error_ex("MT", 0,
|
||||||
"MM7", NULL,
|
"MM7", NULL,
|
||||||
"%s MMSBox Outgoing Queue MMS Send: From %s, to %s, msgsize=%ld",
|
"%s MMSBox Outgoing Queue MMS Send: From %s, to %s, msgsize=%ld: %s",
|
||||||
SEND_ERROR_STR(res),
|
SEND_ERROR_STR(res),
|
||||||
octstr_get_cstr(e->from), octstr_get_cstr(to->rcpt), e->msize);
|
octstr_get_cstr(e->from), octstr_get_cstr(to->rcpt), e->msize, octstr_get_cstr(err));
|
||||||
|
|
||||||
octstr_destroy(new_msgid);
|
octstr_destroy(new_msgid);
|
||||||
octstr_destroy(err);
|
octstr_destroy(err);
|
||||||
|
|
|
@ -639,11 +639,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
sleep(2);
|
sleep(2);
|
||||||
/* Wait for the sender thread, then quit. */
|
/* Wait for the sender thread, then quit. */
|
||||||
gwthread_join(qthread); /* Wait for it to die... */
|
if (qthread >= 0)
|
||||||
|
gwthread_join(qthread); /* Wait for it to die... */
|
||||||
|
|
||||||
if (sendmms_port.port > 0)
|
if (sendmms_port.port > 0 && sthread >= 0)
|
||||||
gwthread_join(sthread);
|
gwthread_join(sthread);
|
||||||
|
|
||||||
mmsbox_settings_cleanup();
|
mmsbox_settings_cleanup();
|
||||||
mms_info(0, "mmsbox", NULL, "Shutdown complete..");
|
mms_info(0, "mmsbox", NULL, "Shutdown complete..");
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,14 @@ extern int rstop;
|
||||||
void mms_dlr_url_put(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr *dlr_url, Octstr *transid);
|
void mms_dlr_url_put(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr *dlr_url, Octstr *transid);
|
||||||
int mms_dlr_url_get(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr **dlr_url, Octstr **transid);
|
int mms_dlr_url_get(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr **dlr_url, Octstr **transid);
|
||||||
void mms_dlr_url_remove(Octstr *msgid, char *rtype, Octstr *mmc_gid);
|
void mms_dlr_url_remove(Octstr *msgid, char *rtype, Octstr *mmc_gid);
|
||||||
|
#if 0
|
||||||
int mmsbox_send_report(Octstr *from, char *report_type,
|
int mmsbox_send_report(Octstr *from, char *report_type,
|
||||||
Octstr *dlr_url, Octstr *status,
|
Octstr *dlr_url, Octstr *status,
|
||||||
Octstr *msgid, Octstr *mmc_id, Octstr *mmc_gid,
|
Octstr *msgid, Octstr *orig_msgid,
|
||||||
|
Octstr *mmc_id, Octstr *mmc_gid,
|
||||||
Octstr *orig_transid, Octstr *uaprof,
|
Octstr *orig_transid, Octstr *uaprof,
|
||||||
time_t uaprof_tstamp);
|
time_t uaprof_tstamp);
|
||||||
|
#endif
|
||||||
void mmsc_receive_func(MmscGrp *m);
|
void mmsc_receive_func(MmscGrp *m);
|
||||||
void mmsbox_outgoing_queue_runner(int *rstop);
|
void mmsbox_outgoing_queue_runner(int *rstop);
|
||||||
|
|
||||||
|
|
|
@ -778,7 +778,8 @@ void mmsbox_settings_cleanup(void)
|
||||||
|
|
||||||
if (admin_port > 0) {
|
if (admin_port > 0) {
|
||||||
http_close_port(admin_port);
|
http_close_port(admin_port);
|
||||||
gwthread_join(admin_thread);
|
if (admin_thread >= 0)
|
||||||
|
gwthread_join(admin_thread);
|
||||||
mms_info(0, "mmsbox", NULL,"Admin port on %d, shutdown", (int)admin_port);
|
mms_info(0, "mmsbox", NULL,"Admin port on %d, shutdown", (int)admin_port);
|
||||||
}
|
}
|
||||||
cdrfs->cleanup();
|
cdrfs->cleanup();
|
||||||
|
|
Loading…
Reference in New Issue