Improved dlr routing for mmsbox
This commit is contained in:
parent
9490de2bc8
commit
bb16c3299a
|
@ -1,3 +1,5 @@
|
||||||
|
2008-09-29 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
* Improved mmsbox DLR routing for status Forwarded
|
||||||
2008-09-15 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2008-09-15 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
* Order of XML tags in MM7 packet changed (shouldn't matter, but...)
|
* Order of XML tags in MM7 packet changed (shouldn't matter, but...)
|
||||||
2008-09-12 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2008-09-12 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
|
|
@ -131,11 +131,11 @@ static int mmsbox_send_report(Octstr *from, char *report_type,
|
||||||
mms_url_fetch_content(HTTP_METHOD_GET, url, rh, octstr_imm(""), &rph, &rb);
|
mms_url_fetch_content(HTTP_METHOD_GET, url, rh, octstr_imm(""), &rph, &rb);
|
||||||
|
|
||||||
/* At what point do we delete it? For now, when we get a read report,
|
/* At what point do we delete it? For now, when we get a read report,
|
||||||
* and also when we get a delivery report that is not 'deferred' or sent
|
* and also when we get a delivery report that is not 'deferred' or sent or forwarded
|
||||||
*/
|
*/
|
||||||
if (strcmp(report_type, "read-report") == 0 ||
|
if (strcmp(report_type, "read-report") == 0 ||
|
||||||
(octstr_case_compare(status, octstr_imm("Deferred")) != 0 &&
|
(octstr_case_compare(status, octstr_imm("Deferred")) != 0 &&
|
||||||
octstr_case_compare(status, octstr_imm("Sent")) != 0))
|
octstr_case_compare(status, octstr_imm("Forwarded")) != 0))
|
||||||
mms_dlr_url_remove(msgid, report_type, mmc_gid);
|
mms_dlr_url_remove(msgid, report_type, mmc_gid);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -401,6 +401,52 @@ static void handle_report_dispatch(MmscGrp *m, Octstr *hfrom, char *rtype, List
|
||||||
octstr_destroy(value3);
|
octstr_destroy(value3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* helper function for queueing delivery reports. */
|
||||||
|
static int queue_dlr(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *msgid, Octstr *status, char *interf)
|
||||||
|
{
|
||||||
|
Octstr *mmc_id = NULL, *qdir;
|
||||||
|
MmsMsg *m = mms_deliveryreport(msgid, from, to, time(NULL), status);
|
||||||
|
List *lto = gwlist_create();
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
gwlist_append(lto, octstr_duplicate(to));
|
||||||
|
qdir = get_mmsbox_queue_dir(from, lto, mmc, &mmc_id); /* get routing info. */
|
||||||
|
|
||||||
|
if (mmc_id != NULL) { /* internal routing. */
|
||||||
|
Octstr *qf;
|
||||||
|
fixup_relayed_report(m, mmc, "delivery-report"); /* fix it up if it is relayed. */
|
||||||
|
qf = qfs->mms_queue_add(from, lto, NULL,
|
||||||
|
mmc->id, mmc_id,
|
||||||
|
0, time(NULL) + default_msgexpiry, m, NULL,
|
||||||
|
NULL, NULL,
|
||||||
|
NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
octstr_get_cstr(qdir),
|
||||||
|
interf,
|
||||||
|
NULL);
|
||||||
|
if (qf) {
|
||||||
|
/* Log to access log */
|
||||||
|
mms_log("Received DLR", from, lto, -1, NULL, NULL, mmc->id, "MMSBox", NULL, NULL);
|
||||||
|
ret = 0;
|
||||||
|
} else
|
||||||
|
ret = -1;
|
||||||
|
octstr_destroy(qf);
|
||||||
|
} else {
|
||||||
|
List *mh = mms_message_headers(m);
|
||||||
|
handle_report_dispatch(mmc, from, "delivery-report", mh, octstr_imm("X-Mms-Status"));
|
||||||
|
|
||||||
|
http_destroy_headers(mh);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gwlist_destroy(lto, (void *)octstr_destroy);
|
||||||
|
octstr_destroy(mmc_id);
|
||||||
|
mms_destroy(m);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
||||||
{
|
{
|
||||||
MmsMsg *m = NULL;
|
MmsMsg *m = NULL;
|
||||||
|
@ -1346,15 +1392,30 @@ static int sendMsg(MmsEnvelope *e)
|
||||||
done:
|
done:
|
||||||
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
||||||
to->process = 0;
|
to->process = 0;
|
||||||
|
|
||||||
|
if (e->msgtype == MMS_MSGTYPE_SEND_REQ ||
|
||||||
|
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF) /* queue dlr as needed. */
|
||||||
|
queue_dlr(mmc, e->from, to->rcpt, new_msgid, octstr_imm("Forwarded"), "MM7-Out");
|
||||||
|
#if 0
|
||||||
mmsbox_send_report(to->rcpt, "delivery-report", e->url1,
|
mmsbox_send_report(to->rcpt, "delivery-report", e->url1,
|
||||||
octstr_imm("Sent"), new_msgid, NULL,
|
octstr_imm("Forwarded"), new_msgid, NULL,
|
||||||
mmc->id, mmc->group_id, otransid, NULL, -1);
|
mmc->id, mmc->group_id, otransid, NULL, -1);
|
||||||
} else if (res == MMS_SEND_ERROR_FATAL && mmc)
|
#endif
|
||||||
|
} else if (res == MMS_SEND_ERROR_FATAL && mmc) {
|
||||||
|
if (e->msgtype == MMS_MSGTYPE_SEND_REQ ||
|
||||||
|
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF) /* queue dlr as needed. */
|
||||||
|
queue_dlr(mmc, e->from, to->rcpt, e->msgId,
|
||||||
|
(e->expiryt != 0 && e->expiryt < tnow) ?
|
||||||
|
octstr_imm("Expired") : octstr_imm("Rejected"),
|
||||||
|
"MM7-Out");
|
||||||
|
#if 0
|
||||||
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, NULL, mmc->id, mmc->group_id, otransid, NULL, -1);
|
e->msgId, NULL, mmc->id, mmc->group_id, otransid, NULL, -1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (res == MMS_SEND_ERROR_FATAL)
|
if (res == MMS_SEND_ERROR_FATAL)
|
||||||
to->process = 0; /* No more attempts. */
|
to->process = 0; /* No more attempts. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue