Skip to content

Commit

Permalink
Set correct share type when listing shares
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Swärd committed Mar 30, 2023
1 parent 1f0e39b commit b6d5f05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Set correct share type when listing shares

This fixes so that we can differentiate between guest/member users for shares.

https://github.com/cs3org/reva/pull/3759
6 changes: 5 additions & 1 deletion internal/http/services/owncloud/ocs/conversions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const (
// ShareTypeUser refers to user shares
ShareTypeUser ShareType = 0

// ShareTypeGuestUser refers to guest user shares
ShareTypeGuestUser ShareType = 4

// ShareTypePublicLink refers to public link shares
ShareTypePublicLink ShareType = 3

Expand Down Expand Up @@ -229,7 +232,8 @@ func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) (*Share
if share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER {
sd.ShareType = ShareTypeUser
sd.ShareWith = LocalUserIDToString(share.Grantee.GetUserId())
if share.GetGrantee().GetUserId().GetType() == userpb.UserType_USER_TYPE_LIGHTWEIGHT {
shareType := share.GetGrantee().GetUserId().GetType()
if shareType == userpb.UserType_USER_TYPE_LIGHTWEIGHT || shareType == userpb.UserType_USER_TYPE_GUEST {
sd.ShareWithUserType = ShareWithUserTypeGuest
} else {
sd.ShareWithUserType = ShareWithUserTypeUser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ func (h *Handler) FindSharees(w http.ResponseWriter, r *http.Request) {
}

func (h *Handler) userAsMatch(u *userpb.User) *conversions.MatchData {
shareType := conversions.ShareTypeUser
if u.Id.Type == userpb.UserType_USER_TYPE_GUEST {
shareType = conversions.ShareTypeGuestUser
}

return &conversions.MatchData{
Label: u.DisplayName,
Value: &conversions.MatchValueData{
ShareType: int(conversions.ShareTypeUser),
ShareType: int(shareType),
// api compatibility with oc10: always use the username
ShareWith: u.Username,
ShareWithAdditionalInfo: h.getAdditionalInfoAttribute(u),
Expand Down

0 comments on commit b6d5f05

Please sign in to comment.