Bartosz Piec
2006-Mar-08 05:11 UTC
[Asterisk-Users] Calls forwarding to numbers only in user's context
Hello, I'm trying to do call forwarding based on this: http://www.voip-info.org/wiki/view/Asterisk+call+forwarding In the extensions.conf file I have several context defined (local, longdistance, mobile, international and so on). Each user can be associated with different context (so can make only i.e. local calls). How to set calls forwarding only to numbers that are available in user's context (so if he has only locals calls he cannot set calls forwarding for mobile phones)? I'm using this for forwarding: [forwarding] ; available for all users ; Unconditional Call Forward exten => _*21*X.,1,DBput(CFIM/${CALLERIDNUM}=${EXTEN:4}) exten => _*21*X.,2,Background(auth-thankyou) exten => _*21*X.,3,Hangup exten => #21#,1,DBdel(CFIM/${CALLERIDNUM}) exten => #21#,2,Background(auth-thankyou) exten => #21#,3,Hangup ; Call Forward on Busy or Unavailable exten => _*61*X.,1,DBput(CFBS/${CALLERIDNUM}=${EXTEN:4}) exten => _*61*X.,2,Background(auth-thankyou) exten => _*61*X.,3,Hangup exten => #61#,1,DBdel(CFBS/${CALLERIDNUM}) exten => #61#,2,Background(auth-thankyou) exten => #61#,3,Hangup [macro-call-forwarding] exten => s,1,Set(temp=${DB(CFIM/${ARG1})}) exten => s,n,GotoIf(${temp}?cfim:nocfim) exten => s,n(cfim),Dial(SIP/${temp}@ruter) ; Unconditional forward exten => s,n(nocfim),NoOp exten => s,n,Dial(SIP/${ARG1},20,tTwW) exten => s,n,Set(temp=${DB(CFBS/${ARG1})}) exten => s,n,GotoIf(${temp}?cfbs:nocfbs) exten => s,n(cfbs),Dial(SIP/${temp}@ruter) ; Forward on busy or unavailable exten => s,n(nocfbs),Goto(s-${DIALSTATUS},1) ; NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER ... [incoming] ; ; Incoming calls. ; exten => XXXXXYY,1,Macro(call-forwarding,YY) -- Best regards, Bartosz Piec
Johnathan Corgan
2006-Mar-09 19:48 UTC
[Asterisk-Users] Calls forwarding to numbers only in user's context
Bartosz Piec wrote:> How to set calls forwarding only to numbers that are available in user's > context (so if he has only locals calls he cannot set calls forwarding > for mobile phones)?When the user sets the forwarding number, store the user's context in the DB along with the forwarding number. Make sure you have an invalid extension 'i' in the user's context as well. For an incoming call, when the Dial returns busy or no answer, execute a jump to the retrieved context/extension. If the user doesn't have the forwarding number in his context, the incoming call will land in the invalid extension. -Johnathan