Browse code

kamailio.cfg: route subscribe for event message-summary to voicemail server

Daniel-Constantin Mierla authored on 15/06/2013 16:23:48
Showing 1 changed files
... ...
@@ -680,21 +680,25 @@ route[PRESENCE] {
680 680
 	if(!is_method("PUBLISH|SUBSCRIBE"))
681 681
 		return;
682 682
 
683
+	if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary") {
684
+		route(TOVOICEMAIL);
685
+		# returns here if no voicemail server is configured
686
+		sl_send_reply("404", "No voicemail service");
687
+		exit;
688
+	}
689
+
683 690
 #!ifdef WITH_PRESENCE
684 691
 	if (!t_newtran())
685 692
 	{
686 693
 		sl_reply_error();
687 694
 		exit;
688
-	};
695
+	}
689 696
 
690 697
 	if(is_method("PUBLISH"))
691 698
 	{
692 699
 		handle_publish();
693 700
 		t_release();
694
-	}
695
-	else
696
-	if( is_method("SUBSCRIBE"))
697
-	{
701
+	} else if(is_method("SUBSCRIBE")) {
698 702
 		handle_subscribe();
699 703
 		t_release();
700 704
 	}
... ...
@@ -868,7 +872,7 @@ route[XMLRPC] {
868 872
 # route to voicemail server
869 873
 route[TOVOICEMAIL] {
870 874
 #!ifdef WITH_VOICEMAIL
871
-	if(!is_method("INVITE"))
875
+	if(!is_method("INVITE|SUBSCRIBE"))
872 876
 		return;
873 877
 
874 878
 	# check if VoiceMail server IP is defined
... ...
@@ -876,11 +880,17 @@ route[TOVOICEMAIL] {
876 880
 		xlog("SCRIPT: VoiceMail rotuing enabled but IP not defined\n");
877 881
 		return;
878 882
 	}
879
-	if($avp(oexten)==$null)
880
-		return;
881
-
882
-	$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
883
+	if(is_method("INVITE")) {
884
+		if($avp(oexten)==$null)
885
+			return;
886
+		$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
883 887
 				+ ":" + $sel(cfg_get.voicemail.srv_port);
888
+	} else {
889
+		if($rU==$null)
890
+			return;
891
+		$ru = "sip:" + $rU + "@" + $sel(cfg_get.voicemail.srv_ip)
892
+				+ ":" + $sel(cfg_get.voicemail.srv_port);
893
+	}
884 894
 	route(RELAY);
885 895
 	exit;
886 896
 #!endif