diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c index 57ffc31..7f58a7f 100644 --- a/mbuni/mmlib/mms_queue.c +++ b/mbuni/mmlib/mms_queue.c @@ -628,7 +628,7 @@ Octstr *mms_queue_add(Octstr *from, List *to, MmsEnvelope *e; Octstr *msgid, *s = NULL, *r = NULL; Octstr *ms, *res = NULL, *xfrom = NULL; - + int mtype; fd = mkqf(qf, subdir, directory); if (fd < 0) { @@ -636,14 +636,20 @@ Octstr *mms_queue_add(Octstr *from, List *to, return NULL; } - res = xmake_qf(qf, subdir); + res = xmake_qf(qf, subdir); + mtype = mms_messagetype(m); + + /* Get MsgID, Fixup if not there and needed. */ + if ((msgid = mms_get_header_value(m, octstr_imm("Message-ID"))) == NULL) { + msgid = mms_maketransid(octstr_get_cstr(res), mmscname); + if (mtype == MMS_MSGTYPE_SEND_REQ) + mms_replace_header_value(m, "Message-ID", octstr_get_cstr(msgid)); + } ms = mms_tobinary(m); /* Convert message to string. */ - msgid = mms_maketransid(octstr_get_cstr(res), mmscname); xfrom = copy_and_clean_address(from); - e = gw_malloc(sizeof *e); /* Make envelope, clear it. */ memset(e, 0, sizeof *e); @@ -653,7 +659,7 @@ Octstr *mms_queue_add(Octstr *from, List *to, e->qf.fd = fd; - e->msgtype = mms_messagetype(m); + e->msgtype = mtype; e->from = xfrom; e->created = time(NULL); e->sendt = senddate; @@ -730,6 +736,7 @@ Octstr *mms_queue_add(Octstr *from, List *to, if (xfrom) octstr_destroy(xfrom); + return res; }