Skip to content

Commit

Permalink
bugfix keep existing hidden states
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Richter <[email protected]>
  • Loading branch information
dragonchaser committed Oct 27, 2023
1 parent 2921b01 commit f9ed562
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/add-hide-flag-to-shares.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ We have added the ability to hide shares through the
ocs/v2.php/apps/files_sharing/api/v1/shares/pending/ endpoint
by appending a POST-Variable called hide which can be true or false.

https://github.com/cs3org/reva/pull/4295
https://github.com/cs3org/reva/pull/4289
https://github.com/cs3org/reva/pull/4194
https://github.com/owncloud/ocis/issues/7589
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) {
}
} else {
if s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED {
s.Hidden = h.getReceivedShareHideFlagFromShareID(r.Context(), shareID)
mountedShares = append(mountedShares, s)
}
}
Expand Down Expand Up @@ -127,7 +128,8 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) {
Share: &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: shareID},
},
State: collaboration.ShareState_SHARE_STATE_ACCEPTED,
State: collaboration.ShareState_SHARE_STATE_ACCEPTED,
Hidden: h.getReceivedShareHideFlagFromShareID(r.Context(), shareID),
MountPoint: &provider.Reference{
Path: mount,
},
Expand All @@ -151,7 +153,8 @@ func (h *Handler) RejectReceivedShare(w http.ResponseWriter, r *http.Request) {
Share: &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: shareID},
},
State: collaboration.ShareState_SHARE_STATE_REJECTED,
State: collaboration.ShareState_SHARE_STATE_REJECTED,
Hidden: h.getReceivedShareHideFlagFromShareID(r.Context(), shareID),
}
updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden"}}

Expand Down Expand Up @@ -238,7 +241,7 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, re
}

data.State = mapState(rs.GetState())
data.Hidden = rs.Hidden
data.Hidden = rs.GetHidden()

h.addFileInfo(ctx, data, info)
h.mapUserIds(r.Context(), client, data)
Expand All @@ -251,6 +254,19 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, re
return data
}

// getReceivedShareHideFlagFromShareId returns the hide flag of a received share based on its ID.
func (h *Handler) getReceivedShareHideFlagFromShareID(ctx context.Context, shareID string) bool {
client, err := h.getClient()
if err != nil {
return false
}
rs, _ := getReceivedShareFromID(ctx, client, shareID)
if rs != nil {
return rs.GetShare().GetHidden()
}
return false
}

// getReceivedShareFromID uses a client to the gateway to fetch a share based on its ID.
func getReceivedShareFromID(ctx context.Context, client gateway.GatewayAPIClient, shareID string) (*collaboration.GetReceivedShareResponse, *response.Response) {
s, err := client.GetReceivedShare(ctx, &collaboration.GetReceivedShareRequest{
Expand Down

0 comments on commit f9ed562

Please sign in to comment.