diff --git a/backend/mailru/api/m1.go b/backend/mailru/api/m1.go index 575510583..91138d9a3 100644 --- a/backend/mailru/api/m1.go +++ b/backend/mailru/api/m1.go @@ -159,71 +159,6 @@ type FolderInfoResponse struct { Email string `json:"email"` } -// ShardInfoResponse ... -type ShardInfoResponse struct { - Email string `json:"email"` - Body struct { - Video []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"video"` - ViewDirect []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"view_direct"` - WeblinkView []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"weblink_view"` - WeblinkVideo []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"weblink_video"` - WeblinkGet []struct { - Count int `json:"count"` - URL string `json:"url"` - } `json:"weblink_get"` - Stock []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"stock"` - WeblinkThumbnails []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"weblink_thumbnails"` - PublicUpload []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"public_upload"` - Auth []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"auth"` - Web []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"web"` - View []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"view"` - Upload []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"upload"` - Get []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"get"` - Thumbnails []struct { - Count string `json:"count"` - URL string `json:"url"` - } `json:"thumbnails"` - } `json:"body"` - Time int64 `json:"time"` - Status int `json:"status"` -} - // CleanupResponse ... type CleanupResponse struct { Email string `json:"email"` diff --git a/backend/mailru/mailru.go b/backend/mailru/mailru.go index 316e39558..e35c4e334 100644 --- a/backend/mailru/mailru.go +++ b/backend/mailru/mailru.go @@ -1861,30 +1861,30 @@ func (f *Fs) uploadShard(ctx context.Context) (string, error) { return f.shardURL, nil } - token, err := f.accessToken() - if err != nil { - return "", err - } - opts := rest.Opts{ - Method: "GET", - Path: "/api/m1/dispatcher", - Parameters: url.Values{ - "client_id": {api.OAuthClientID}, - "access_token": {token}, - }, + RootURL: api.DispatchServerURL, + Method: "GET", + Path: "/u", } - var info api.ShardInfoResponse + var ( + res *http.Response + url string + err error + ) err = f.pacer.Call(func() (bool, error) { - res, err := f.srv.CallJSON(ctx, &opts, nil, &info) - return shouldRetry(res, err, f, &opts) + res, err = f.srv.Call(ctx, &opts) + if err == nil { + url, err = readBodyWord(res) + } + return fserrors.ShouldRetry(err), err }) if err != nil { + closeBody(res) return "", err } - f.shardURL = info.Body.Upload[0].URL + f.shardURL = url f.shardExpiry = time.Now().Add(shardExpirySec * time.Second) fs.Debugf(f, "new upload shard: %s", f.shardURL)