[Asterisk-code-review] res_pjsip_messaging: Rewrite To: to normalize recipient (...asterisk[13.29])
Brian J. Murrell
asteriskteam at digium.com
Wed Oct 16 17:35:13 CDT 2019
Brian J. Murrell has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13064
Change subject: res_pjsip_messaging: Rewrite To: to normalize recipient
......................................................................
res_pjsip_messaging: Rewrite To: to normalize recipient
The To: header should be consistent on outgoing messages and represent
the "logical" receipent, which is the user at the_asterisk.system.
ASTERISK-28513 #close
Change-Id: Iab8d472081d22ed80a3abf3b34833d898306ac8e
---
M res/res_pjsip_messaging.c
1 file changed, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/64/13064/1
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 76d37f2..7463a73 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -43,6 +43,7 @@
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/taskprocessor.h"
+#include "asterisk/paths.h"
const pjsip_method pjsip_message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} };
@@ -230,10 +231,16 @@
parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, to, strlen(to),
PJSIP_PARSE_URI_AS_NAMEADDR);
if (parsed_name_addr) {
- if (pj_strlen(&parsed_name_addr->display)) {
- pjsip_name_addr *name_addr =
- (pjsip_name_addr *) PJSIP_MSG_TO_HDR(tdata->msg)->uri;
+ pjsip_sip_uri *uri;
+ pjsip_name_addr *name_addr =
+ (pjsip_name_addr *) PJSIP_MSG_TO_HDR(tdata->msg)->uri;
+ uri = pjsip_uri_get_uri(name_addr);
+ if (!ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
+ pj_strdup2(tdata->pool, &uri->host, ast_config_AST_SYSTEM_NAME);
+ } else
+ ast_log(LOG_WARNING, "Unable to rewrite MESSAGE to systemname because systemname (%s) is empty\n", ast_config_AST_SYSTEM_NAME);
+ if (pj_strlen(&parsed_name_addr->display)) {
pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
}
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13064
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13.29
Gerrit-Change-Id: Iab8d472081d22ed80a3abf3b34833d898306ac8e
Gerrit-Change-Number: 13064
Gerrit-PatchSet: 1
Gerrit-Owner: Brian J. Murrell <brian at interlinx.bc.ca>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191016/ee0b70bf/attachment-0001.html>
More information about the asterisk-code-review
mailing list