Skip to content

Commit

Permalink
all: use cs3.types.UserId instead of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
labkode committed Jun 28, 2019
1 parent 8595736 commit dee5bde
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ func (s *service) toInfo(md *storage.MD) *storageproviderv0alphapb.ResourceInfo
Type: getResourceType(md.IsDir),
Id: id,
Path: md.Path,
Owner: md.Owner,
Owner: &typespb.UserId{OpaqueId: md.Owner},
Checksum: checksum,
Etag: md.Etag,
MimeType: md.Mime,
Expand Down
17 changes: 3 additions & 14 deletions cmd/revad/svcs/httpsvcs/ocssvc/shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ func (h *SharesHandler) listShares(w http.ResponseWriter, r *http.Request) {
func (h *SharesHandler) addFileInfo(s *ShareData, info *storageproviderv0alphapb.ResourceInfo) {
if info != nil {
// TODO The owner is not set in the storage stat metadata ...
owner := h.resolveUserString(info.Owner)
owner := h.resolveUserID(info.Owner)
s.MimeType = info.MimeType
// TODO STime: &typespb.Timestamp{Seconds: info.Mtime.Seconds, Nanos: info.Mtime.Nanos},
s.StorageID = info.Id.StorageId
Expand Down Expand Up @@ -731,8 +731,8 @@ func (h *SharesHandler) addFileInfo(s *ShareData, info *storageproviderv0alphapb

// TODO(jfd) merge userShare2ShareData with publicShare2ShareData
func (h *SharesHandler) userShare2ShareData(share *usershareproviderv0alphapb.Share) *ShareData {
creator := h.resolveUserString(share.Creator)
owner := h.resolveUserString(share.Owner)
creator := h.resolveUserID(share.Creator)
owner := h.resolveUserID(share.Owner)
grantee := h.resolveUserID(share.Grantee.Id)
sd := &ShareData{
Permissions: userSharePermissions2OCSPermissions(share.GetPermissions()),
Expand Down Expand Up @@ -781,17 +781,6 @@ func (h *SharesHandler) resolveUserID(userID *typespb.UserId) *user.User {
}
}

// TODO do user lookup and cache users
func (h *SharesHandler) resolveUserString(userID string) *user.User {
return &user.User{
ID: &user.ID{
OpaqueID: userID,
},
Username: userID,
DisplayName: userID,
}
}

func (h *SharesHandler) publicShare2ShareData(share *publicsharev0alphapb.PublicShare) *ShareData {
creator := h.resolveUserID(share.Creator)
owner := h.resolveUserID(share.Owner)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require (
github.com/aws/aws-sdk-go v1.20.11
github.com/cheggaaa/pb v1.0.28
github.com/coreos/go-oidc v2.0.0+incompatible
github.com/cs3org/go-cs3apis v0.0.0-20190605095738-336edf0a3a8a
github.com/cs3org/go-cs3apis v0.0.0-20190628075811-ed6d4fdf3b77
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fatih/color v1.7.0 // indirect
github.com/go-sql-driver/mysql v1.4.1
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/coreos/go-oidc v2.0.0+incompatible h1:+RStIopZ8wooMx+Vs5Bt8zMXxV1ABl5LbakNExNmZIg=
github.com/coreos/go-oidc v2.0.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cs3org/go-cs3apis v0.0.0-20190605095738-336edf0a3a8a h1:mbEa0S9UHg03/aST6J5klOdte8+y6PbNSUuDDpt6UyE=
github.com/cs3org/go-cs3apis v0.0.0-20190605095738-336edf0a3a8a/go.mod h1:rw9YcRp+3DtWMCKDKhjopFvpJcXE9rTCd7qxAm5FPIo=
github.com/cs3org/go-cs3apis v0.0.0-20190628075811-ed6d4fdf3b77 h1:hFTd3vwMU3lvOMbVakkc64J7Kben5hjWl7lMmnCaOJs=
github.com/cs3org/go-cs3apis v0.0.0-20190628075811-ed6d4fdf3b77/go.mod h1:8Pa27iO6PKnoW9tMIgICY2etfcwKhePWC5DZ/HX1lOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
Expand Down Expand Up @@ -132,8 +132,6 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 h1:xtNn7qFlagY2mQNFHMSRPjT2RkOV4OXM7P5TVy9xATo=
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down

0 comments on commit dee5bde

Please sign in to comment.