Ensure voice downloads are authenticated

This commit is contained in:
Tyler 2019-10-14 19:18:25 -04:00
parent f9206c7c99
commit ffe0ef235d
2 changed files with 8 additions and 3 deletions

View File

@ -90,7 +90,8 @@ type VoiceServerUpdate struct {
type VoiceProcessingData struct {
io.ReadCloser
Client *http.Client
node *Node
UserID string
URL string
File string
@ -99,7 +100,11 @@ type VoiceProcessingData struct {
}
func (v *VoiceProcessingData) open() error {
res, err := v.Client.Get(v.URL)
req, err := http.NewRequest(http.MethodGet, v.URL, nil)
req.Header.Set("Authorization", v.node.config.Password)
res, err := v.node.client.Do(req)
if err != nil {
return err

View File

@ -208,7 +208,7 @@ func (node *Node) onEvent(v *fastjson.Value, msg []byte) error {
track := jsonStringValue(v, "track")
data := &VoiceProcessingData{
Client: node.client,
node: node,
UserID: jsonStringValue(v, "userId"),
URL: fmt.Sprintf("%s/audio/%s", node.config.REST, track),
File: track,