From b005d8dd53d1f4e3084bf1dfcfcf731d45805655 Mon Sep 17 00:00:00 2001 From: David Vossel Date: Tue, 21 Jun 2011 15:49:23 +0000 Subject: [PATCH] Fixes issue with finding correct extension when message context is used. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@324302 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 70f8d7dc86..41d539ecd6 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -16116,6 +16116,15 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a } } + /* Override the context with the message context _BEFORE_ + * getting the destination. This way we can guarantee the correct + * extension is used in the message context when it is present. */ + if (!ast_strlen_zero(p->messagecontext)) { + ast_string_field_set(p, context, p->messagecontext); + } else if (!ast_strlen_zero(sip_cfg.messagecontext)) { + ast_string_field_set(p, context, sip_cfg.messagecontext); + } + get_destination(p, NULL, NULL); if (!(msg = ast_msg_alloc())) { @@ -16132,14 +16141,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a res = ast_msg_set_to(msg, "%s", to); res |= ast_msg_set_from(msg, "%s", get_in_brackets(from)); res |= ast_msg_set_body(msg, "%s", ast_str_buffer(buf)); - - if (!ast_strlen_zero(p->messagecontext)) { - res |= ast_msg_set_context(msg, "%s", p->messagecontext); - } else if (!ast_strlen_zero(sip_cfg.messagecontext)) { - res |= ast_msg_set_context(msg, "%s", sip_cfg.messagecontext); - } else { - res |= ast_msg_set_context(msg, "%s", p->context); - } + res |= ast_msg_set_context(msg, "%s", p->context); if (!ast_strlen_zero(p->peername)) { res |= ast_msg_set_var(msg, "SIP_PEERNAME", p->peername);