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 {
|
type VoiceProcessingData struct {
|
||||||
io.ReadCloser
|
io.ReadCloser
|
||||||
|
|
||||||
Client *http.Client
|
node *Node
|
||||||
|
|
||||||
UserID string
|
UserID string
|
||||||
URL string
|
URL string
|
||||||
File string
|
File string
|
||||||
|
@ -99,7 +100,11 @@ type VoiceProcessingData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VoiceProcessingData) open() error {
|
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 {
|
if err != nil {
|
||||||
return err
|
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")
|
track := jsonStringValue(v, "track")
|
||||||
|
|
||||||
data := &VoiceProcessingData{
|
data := &VoiceProcessingData{
|
||||||
Client: node.client,
|
node: node,
|
||||||
UserID: jsonStringValue(v, "userId"),
|
UserID: jsonStringValue(v, "userId"),
|
||||||
URL: fmt.Sprintf("%s/audio/%s", node.config.REST, track),
|
URL: fmt.Sprintf("%s/audio/%s", node.config.REST, track),
|
||||||
File: track,
|
File: track,
|
||||||
|
|
Loading…
Reference in New Issue