Ensure voice downloads are authenticated
This commit is contained in:
parent
f9206c7c99
commit
ffe0ef235d
9
model.go
9
model.go
|
@ -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
|
||||
|
|
2
node.go
2
node.go
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue