cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1983
Views
6
Helpful
2
Replies

Lua Script Remote-Party-ID

nikhilrajan
Level 1
Level 1

Hi All,

I need to modify this script to change this header. Can any one pls help me on this.


Remote-Party-ID "London Test" ;party=calling;screen=yes;privacy=off

To

Remote-Party-ID "London Test" ;party=calling;screen=yes;privacy=full

The script is

M = {}

function M.outbound_INVITE(msg)

local fromtag = msg:getHeaderValueParameter("From", "tag")

local pai = msg:getHeader("P-Asserted-Identity")

local uri = string.match(pai, "(<sip:%+4420.+>)")

local uri2 = string.match(pai, "(<sip:%+441785.+>)")

if uri or uri2

then

msg:modifyHeader("From", "Anonymous <sip:anonymous@anonymous.invalid>")

msg:addHeaderValueParameter("From", "tag", fromtag)

msg:addHeader("Privacy", "id")

end

end

return M


I tried applying below but it failed.


function M.outbound_INVITE(msg)

local remote = msg:getHeader("Remote-Party-ID")

local privacy = string.find(remote, "off")

local target = string.sub(remote, privacy)

local replace = string.gsub(target, "full")

msg:modifyHeader("Remote-Party-ID", replace)

end

return M


Can anyone pls help me on this?


Regards,

Nikhil

1 Accepted Solution

Accepted Solutions

Mark Stover
Cisco Employee
Cisco Employee

It would be easier if you don't try to use the indexes returned by string.find:

local remote = msg:getHeader("Remote-Party-ID")

local replace = string.gsub(remote, "privacy=off", "privacy=full")

msg:modifyHeader("Remote-Party-ID", replace)

Mark

View solution in original post

2 Replies 2

Mark Stover
Cisco Employee
Cisco Employee

It would be easier if you don't try to use the indexes returned by string.find:

local remote = msg:getHeader("Remote-Party-ID")

local replace = string.gsub(remote, "privacy=off", "privacy=full")

msg:modifyHeader("Remote-Party-ID", replace)

Mark

Thanks a lot Mark. It worked

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: