2017-04-12 08:27:57 -04:00
|
|
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
2016-09-15 09:35:44 -03:00
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
2017-01-13 13:53:37 -05:00
|
|
|
|
|
|
|
|
l4g "github.com/alecthomas/log4go"
|
2017-09-06 23:05:10 -07:00
|
|
|
"github.com/mattermost/mattermost-server/app"
|
|
|
|
|
"github.com/mattermost/mattermost-server/utils"
|
2016-09-15 09:35:44 -03:00
|
|
|
)
|
|
|
|
|
|
2017-09-22 12:54:27 -05:00
|
|
|
func (api *API) InitWebrtc() {
|
2016-09-15 09:35:44 -03:00
|
|
|
l4g.Debug(utils.T("api.webrtc.init.debug"))
|
|
|
|
|
|
2017-09-22 12:54:27 -05:00
|
|
|
api.BaseRoutes.Webrtc.Handle("/token", api.ApiUserRequired(webrtcToken)).Methods("POST")
|
2016-09-15 09:35:44 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func webrtcToken(c *Context, w http.ResponseWriter, r *http.Request) {
|
2017-04-16 21:14:31 -04:00
|
|
|
result, err := app.GetWebrtcInfoForSession(c.Session.Id)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
2016-09-15 09:35:44 -03:00
|
|
|
c.Err = err
|
|
|
|
|
return
|
|
|
|
|
}
|
2016-11-04 13:05:32 -03:00
|
|
|
|
2017-04-16 21:14:31 -04:00
|
|
|
w.Write([]byte(result.ToJson()))
|
2016-11-04 13:05:32 -03:00
|
|
|
}
|