fix version 1
This commit is contained in:
@@ -36,8 +36,15 @@ func GetShare(ctx context.Context, in *pb.IdentRequest) (reply *pb.CloudShareIte
|
||||
}
|
||||
|
||||
if err := query.First(&share).Error; err != nil {
|
||||
printer.Error("Share not found: %v", err)
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
// 非创建者:凭分享 identity 可读取公开分享,使收件人能够取到分享指向的资源
|
||||
if in.Id > 0 || in.Identity == "" {
|
||||
printer.Error("Share not found: %v", err)
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
if err := impl.DBService.Where("identity = ? AND is_public = ?", in.Identity, true).First(&share).Error; err != nil {
|
||||
printer.Error("Share not found: %v", err)
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否过期
|
||||
@@ -45,13 +52,19 @@ func GetShare(ctx context.Context, in *pb.IdentRequest) (reply *pb.CloudShareIte
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// 非创建者读取分享时不回传分享密码
|
||||
password := share.Password
|
||||
if share.PassportID != auth.ID {
|
||||
password = ""
|
||||
}
|
||||
|
||||
reply = &pb.CloudShareItem{
|
||||
Id: uint64(share.ID),
|
||||
Identity: share.Identity,
|
||||
ShareType: share.ShareType,
|
||||
ResourceId: uint64(share.ResourceID),
|
||||
ShareToken: share.ShareToken,
|
||||
Password: share.Password,
|
||||
Password: password,
|
||||
ExpiresAt: share.ExpiresAt.Format(time.RFC3339),
|
||||
ViewCount: int32(share.ViewCount),
|
||||
DownloadCount: int32(share.DownloadCount),
|
||||
|
||||
Reference in New Issue
Block a user