Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions drivers/123_open/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
type Open123 struct {
model.Storage
Addition
UID uint64
}

func (d *Open123) Config() driver.Config {
Expand Down Expand Up @@ -83,15 +84,15 @@ func (d *Open123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
}, nil
}

u, err := d.getUserInfo()
uid, err := d.getUID()
if err != nil {
return nil, err
}

duration := time.Duration(d.DirectLinkValidDuration) * time.Minute

newURL, err := d.SignURL(res.Data.URL, d.DirectLinkPrivateKey,
u.Data.UID, duration)
uid, duration)
if err != nil {
return nil, err
}
Expand Down
26 changes: 13 additions & 13 deletions drivers/123_open/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ type RefreshTokenResp struct {
type UserInfoResp struct {
BaseResp
Data struct {
UID uint64 `json:"uid"`
Username string `json:"username"`
DisplayName string `json:"displayName"`
HeadImage string `json:"headImage"`
Passport string `json:"passport"`
Mail string `json:"mail"`
SpaceUsed int64 `json:"spaceUsed"`
SpacePermanent int64 `json:"spacePermanent"`
SpaceTemp int64 `json:"spaceTemp"`
SpaceTempExpr string `json:"spaceTempExpr"`
Vip bool `json:"vip"`
DirectTraffic int64 `json:"directTraffic"`
IsHideUID bool `json:"isHideUID"`
UID uint64 `json:"uid"`
// Username string `json:"username"`
// DisplayName string `json:"displayName"`
// HeadImage string `json:"headImage"`
// Passport string `json:"passport"`
// Mail string `json:"mail"`
// SpaceUsed int64 `json:"spaceUsed"`
// SpacePermanent int64 `json:"spacePermanent"`
// SpaceTemp int64 `json:"spaceTemp"`
// SpaceTempExpr int64 `json:"spaceTempExpr"`
// Vip bool `json:"vip"`
// DirectTraffic int64 `json:"directTraffic"`
// IsHideUID bool `json:"isHideUID"`
} `json:"data"`
}

Expand Down
14 changes: 13 additions & 1 deletion drivers/123_open/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ func (d *Open123) getUserInfo() (*UserInfoResp, error) {
return &resp, nil
}

func (d *Open123) getUID() (uint64, error) {
if d.UID != 0 {
return d.UID, nil
}
resp, err := d.getUserInfo()
if err != nil {
return 0, err
}
d.UID = resp.Data.UID
return resp.Data.UID, nil
}

func (d *Open123) getFiles(parentFileId int64, limit int, lastFileId int64) (*FileListResp, error) {
var resp FileListResp

Expand Down Expand Up @@ -200,7 +212,7 @@ func (d *Open123) getDirectLink(fileId int64) (*DirectLinkResp, error) {

_, err := d.Request(DirectLink, http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(map[string]string{
"fileId": strconv.FormatInt(fileId, 10),
"fileID": strconv.FormatInt(fileId, 10),
})
}, &resp)
if err != nil {
Expand Down