Skip to content

Commit

Permalink
Add intent to request and ommit empty recipient fields.
Browse files Browse the repository at this point in the history
Fix #2
  • Loading branch information
gnojus committed Oct 28, 2020
1 parent e224f2c commit 9755a86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions transfer/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ type headers map[string]string

type requestData struct {
Security_hash string `json:"security_hash"`
Domain_user_id string `json:"domain_user_id"`
RecipientId string `json:"recipient_id"`
Domain_user_id string `json:"domain_user_id,omitempty"`
RecipientId string `json:"recipient_id,omitempty"`
Intent string `json:"intent"`
}

type transferData struct {
Expand Down Expand Up @@ -92,7 +93,11 @@ func getDownloadLink(client *http.Client, data transferData) (URL string, err er
if URL, ok := result["direct_link"].(string); ok {
return URL, nil
}
return "", errors.New("Unable to find direct link")
message := "Unable to get direct link"
if e, ok := result["message"].(string); ok {
message += ": " + e
}
return "", errors.New(message)
}

func getTransferData(resp *http.Response) (out transferData, err error) {
Expand All @@ -115,6 +120,7 @@ func getTransferData(resp *http.Response) (out transferData, err error) {
return out, errors.New("Unable to get domain user id")
}
out.req_data.RecipientId, _ = findVar(`"recipient_id":"`, body)
out.req_data.Intent = "entire_transfer"

if out.wt_session, ok = getCookieValue("_wt_session", resp); !ok {
return out, errors.New("Unable to get _wt_session cookie")
Expand Down
5 changes: 3 additions & 2 deletions wedl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package main

import (
"fmt"
"os"

"github.com/Nojus297/wedl/cli"
"github.com/docopt/docopt-go"
"os"
)

var version string = "v0.1.0"
var version string = "unspecified"

func main() {
usage := `
Expand Down

0 comments on commit 9755a86

Please sign in to comment.