Add freeswitch integration
This commit is contained in:
parent
3abce75db4
commit
3908042abd
|
@ -1,3 +1,3 @@
|
||||||
FROM xena/lapis
|
FROM xena/lapis
|
||||||
|
|
||||||
|
RUN moonrocks install xml
|
||||||
|
|
10
app.moon
10
app.moon
|
@ -37,12 +37,14 @@ class App extends lapis.Application
|
||||||
@params.password_again = nil
|
@params.password_again = nil
|
||||||
@params.csrf_token = nil
|
@params.csrf_token = nil
|
||||||
@params.extension = "9001"
|
@params.extension = "9001"
|
||||||
|
@params.registrar_password = encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!)
|
||||||
|
|
||||||
if Users\find email: @params.email
|
if Users\find email: @params.email
|
||||||
return status: 500, "User with that email already exists"
|
return status: 500, "User with that email already exists"
|
||||||
|
|
||||||
user = Users\create @params
|
user = Users\create @params
|
||||||
user\write_session @
|
user\write_session @
|
||||||
|
@session.sippw = @params.registrar_password
|
||||||
|
|
||||||
"Hi " .. user.name
|
"Hi " .. user.name
|
||||||
}
|
}
|
||||||
|
@ -70,3 +72,11 @@ class App extends lapis.Application
|
||||||
else
|
else
|
||||||
return status: 500, "bad password"
|
return status: 500, "bad password"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[freeswitch: "/freeswitch"]: respond_to {
|
||||||
|
POST: =>
|
||||||
|
uid = @params["user"] or @params["sip_auth_username"]
|
||||||
|
@user = Users\find id: uid
|
||||||
|
|
||||||
|
render: true, layout: false
|
||||||
|
}
|
||||||
|
|
|
@ -23,4 +23,7 @@ import add_column, create_table, types from require "lapis.db.schema"
|
||||||
|
|
||||||
[5]: =>
|
[5]: =>
|
||||||
add_column "users", "is_agent", types.boolean
|
add_column "users", "is_agent", types.boolean
|
||||||
|
|
||||||
|
[6]: =>
|
||||||
|
add_column "users", "registrar_password", types.text
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import Widget from require "lapis.html"
|
||||||
|
|
||||||
|
class Freeswitch extends Widget
|
||||||
|
content: =>
|
||||||
|
document type: "freeswitch/xml", ->
|
||||||
|
section name: "directory", ->
|
||||||
|
domain name: "$${domain}", ->
|
||||||
|
params ->
|
||||||
|
param name: "dial-string", value: "{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"
|
||||||
|
groups ->
|
||||||
|
group name: "default", ->
|
||||||
|
users ->
|
||||||
|
user id: "#{@user.id}", ->
|
||||||
|
params ->
|
||||||
|
param name: "password", value: "#{@user.registrar_password}"
|
||||||
|
variables ->
|
||||||
|
variable name: "accountcode", value: "#{@user.id}"
|
||||||
|
variable name: "user_context", value: "default"
|
Loading…
Reference in New Issue