From 9748e886211a43b1754c3f416f7c8d661e79c909 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Tue, 1 Jan 2008 06:45:16 +0000 Subject: [PATCH] minor fix to message routing --- mbuni/mmsbox/mmsbox_cfg.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index 466d4e8..07c737d 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -504,17 +504,21 @@ MmscGrp *get_handler_mmc(Octstr *id, Octstr *to, Octstr *from) /* handle message routing. */ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m, - Octstr **mmc_id) { - + Octstr **mmc_id) +{ + if (m->reroute) { *mmc_id = m->reroute_mmsc_id ? octstr_duplicate(m->reroute_mmsc_id) : NULL; return outgoing_qdir; } else { Octstr *_mcid, *qdir = NULL; + Octstr *fto; - if (gwlist_len(to) > 0) { /* we route based on first recipient XXX */ - Octstr *fto = gwlist_extract_first(to); + if (gwlist_len(to) > 0 && + (fto = gwlist_extract_first(to)) != NULL) { /* we route based on first recipient XXX */ + Octstr *xto = octstr_duplicate(fto); Octstr *xfrom = octstr_duplicate(from); + if (unified_prefix) _mms_fixup_address(&xfrom, octstr_get_cstr(unified_prefix), 0); @@ -523,10 +527,17 @@ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m, _mcid = rfs->mmsbox_resolve(xfrom,fto,octstr_get_cstr(m->id), rfs_data, rfs_settings); - if (unified_prefix) - _mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), 1); - if (fto) - gwlist_insert(to, 0, fto); /* put it back, after modification. */ + /* modify what was sent to us. */ + if (octstr_len(_mcid) == 0) { /* put recipient back, unmodified if incoming only. */ + gwlist_insert(to, 0, xto); + octstr_destroy(fto); + } else { + if (unified_prefix) + _mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), 1); + gwlist_insert(to, 0, fto); + octstr_destroy(xto); + } + if (xfrom) { octstr_delete(from, 0, octstr_len(from)); octstr_append(from, xfrom); @@ -535,7 +546,7 @@ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m, } else _mcid = NULL; - if (_mcid == NULL || octstr_len(_mcid) == 0) { + if (octstr_len(_mcid) == 0) { *mmc_id = NULL; qdir = incoming_qdir; } else {