Bump reva

This commit is contained in:
André Duffeck
2026-03-06 14:59:29 +01:00
parent 39bf204437
commit 2146e970ee
98 changed files with 5480 additions and 2869 deletions
@@ -25,6 +25,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/opencloud-eu/reva/v2/pkg/appauth"
"github.com/opencloud-eu/reva/v2/pkg/appauth/manager/registry"
"github.com/opencloud-eu/reva/v2/pkg/appctx"
"github.com/opencloud-eu/reva/v2/pkg/errtypes"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/status"
@@ -104,8 +105,10 @@ func (s *service) UnprotectedEndpoints() []string {
}
func (s *service) GenerateAppPassword(ctx context.Context, req *appauthpb.GenerateAppPasswordRequest) (*appauthpb.GenerateAppPasswordResponse, error) {
logger := appctx.GetLogger(ctx)
pwd, err := s.am.GenerateAppPassword(ctx, req.TokenScope, req.Label, req.Expiration)
if err != nil {
logger.Debug().Err(err).Msg("error generating app password")
return &appauthpb.GenerateAppPasswordResponse{
Status: status.NewInternal(ctx, "error generating app password"),
}, nil
@@ -148,7 +151,7 @@ func (s *service) GetAppPassword(ctx context.Context, req *appauthpb.GetAppPassw
pwd, err := s.am.GetAppPassword(ctx, req.User, req.Password)
if err != nil {
return &appauthpb.GetAppPasswordResponse{
Status: status.NewInternal(ctx, "error getting app password via username/password"),
Status: status.NewStatusFromErrType(ctx, "error getting app password via username/password", err),
}, nil
}
@@ -23,8 +23,11 @@ import (
"fmt"
"net/url"
"path"
"slices"
"strings"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
incoming "github.com/cs3org/go-cs3apis/cs3/ocm/incoming/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
@@ -332,7 +335,7 @@ func (s *svc) handleTransfer(ctx context.Context, share *ocm.ReceivedShare, tran
if !ok {
return errors.New("gateway: unable to retrieve transfer protocol")
}
sourceURI := protocol.SourceUri
sourceURI := protocol.Uri
// get the webdav endpoint of the grantee's idp
var granteeIdp string
@@ -434,11 +437,29 @@ func (s *svc) GetReceivedOCMShare(ctx context.Context, req *ocm.GetReceivedOCMSh
return res, nil
}
func (s *svc) getTransferProtocol(share *ocm.ReceivedShare) (*ocm.TransferProtocol, bool) {
func (s *svc) getTransferProtocol(share *ocm.ReceivedShare) (*ocm.WebDAVProtocol, bool) {
for _, p := range share.Protocols {
if d, ok := p.Term.(*ocm.Protocol_TransferOptions); ok {
return d.TransferOptions, true
if d, ok := p.Term.(*ocm.Protocol_WebdavOptions); ok {
if slices.Contains(d.WebdavOptions.AccessTypes, ocm.AccessType_ACCESS_TYPE_DATATX) {
return d.WebdavOptions, true
}
}
}
return nil, false
}
func (s *svc) CreateOCMIncomingShare(context.Context, *incoming.CreateOCMIncomingShareRequest) (*incoming.CreateOCMIncomingShareResponse, error) {
return nil, errtypes.NotSupported("gateway: CreateOCMIncomingShare is not supported")
}
func (s *svc) UpdateOCMIncomingShare(context.Context, *incoming.UpdateOCMIncomingShareRequest) (*incoming.UpdateOCMIncomingShareResponse, error) {
return nil, errtypes.NotSupported("gateway: UpdateOCMIncomingShare is not supported")
}
func (s *svc) DeleteOCMIncomingShare(context.Context, *incoming.DeleteOCMIncomingShareRequest) (*incoming.DeleteOCMIncomingShareResponse, error) {
return nil, errtypes.NotSupported("gateway: DeleteOCMIncomingShare is not supported")
}
func (s *svc) ListExistingOCMShares(context.Context, *ocm.ListOCMSharesRequest) (*gateway.ListExistingOCMSharesResponse, error) {
return nil, errtypes.NotSupported("gateway: ListExistingOCMShares is not supported")
}
@@ -144,7 +144,11 @@ func (s *service) GetGroupByClaim(ctx context.Context, req *grouppb.GetGroupByCl
}
func (s *service) FindGroups(ctx context.Context, req *grouppb.FindGroupsRequest) (*grouppb.FindGroupsResponse, error) {
groups, err := s.groupmgr.FindGroups(ctx, req.Filter, req.SkipFetchingMembers)
if len(req.Filters) > 1 || req.Filters[0].GetType() != grouppb.Filter_TYPE_QUERY {
return nil, fmt.Errorf("only one query filter supported")
}
groups, err := s.groupmgr.FindGroups(ctx, req.Filters[0].GetQuery(), req.SkipFetchingMembers)
if err != nil {
return &grouppb.FindGroupsResponse{
Status: status.NewInternal(ctx, "error finding groups"),
@@ -201,38 +201,6 @@ func (s *service) getWebappProtocol(share *ocm.Share) *ocmd.Webapp {
}
}
func (s *service) getDataTransferProtocol(ctx context.Context, share *ocm.Share) *ocmd.Datatx {
var size uint64
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return nil
}
// get the path of the share
statRes, err := gatewayClient.Stat(ctx, &providerpb.StatRequest{
Ref: &providerpb.Reference{
ResourceId: share.ResourceId,
},
})
if err != nil {
return nil
}
err = s.walker.Walk(ctx, statRes.GetInfo().GetId(), func(path string, info *providerpb.ResourceInfo, err error) error {
if info.Type == providerpb.ResourceType_RESOURCE_TYPE_FILE {
size += info.Size
}
return nil
})
if err != nil {
return nil
}
return &ocmd.Datatx{
SourceURI: s.webdavURL(ctx, share),
Size: size,
}
}
func (s *service) getProtocols(ctx context.Context, share *ocm.Share) ocmd.Protocols {
var p ocmd.Protocols
for _, m := range share.AccessMethods {
@@ -242,8 +210,6 @@ func (s *service) getProtocols(ctx context.Context, share *ocm.Share) ocmd.Proto
newProtocol = s.getWebdavProtocol(ctx, share, t)
case *ocm.AccessMethod_WebappOptions:
newProtocol = s.getWebappProtocol(share)
case *ocm.AccessMethod_TransferOptions:
newProtocol = s.getDataTransferProtocol(ctx, share)
}
if newProtocol != nil {
p = append(p, newProtocol)
@@ -365,7 +365,7 @@ func (s *Service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
if ifMatch != "" {
if !validateIfMatch(ifMatch, sRes.GetInfo()) {
return &provider.InitiateFileUploadResponse{
Status: status.NewFailedPrecondition(ctx, errors.New("etag mismatch"), "etag mismatch"),
Status: status.NewAborted(ctx, errors.New("etag mismatch"), "etag mismatch"),
}, nil
}
metadata["if-match"] = ifMatch
@@ -375,7 +375,7 @@ func (s *Service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
metadata["if-unmodified-since"] = utils.TSToTime(ifUnmodifiedSince).Format(time.RFC3339Nano)
if !validateIfUnmodifiedSince(ifUnmodifiedSince, sRes.GetInfo()) {
return &provider.InitiateFileUploadResponse{
Status: status.NewFailedPrecondition(ctx, errors.New("resource has been modified"), "resource has been modified"),
Status: status.NewAborted(ctx, errors.New("resource has been modified"), "resource has been modified"),
}, nil
}
}
@@ -517,7 +517,7 @@ func (s *Service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt
case errtypes.NotSupported:
// if trying to create a user home fall back to CreateHome
if u, ok := ctxpkg.ContextGetUser(ctx); ok && req.Type == "personal" && utils.UserEqual(req.GetOwner().GetId(), u.GetId()) {
if err := s.Storage.CreateHome(ctx); err != nil {
if err := s.Storage.CreateHome(ctx); err != nil { //nolint:staticcheck // falling back to deprecated method if the new one is not supported by the driver
st = status.NewInternal(ctx, "error creating home")
} else {
st = status.NewOK(ctx)
@@ -183,9 +183,13 @@ func (s *service) GetUserByClaim(ctx context.Context, req *userpb.GetUserByClaim
}
func (s *service) FindUsers(ctx context.Context, req *userpb.FindUsersRequest) (*userpb.FindUsersResponse, error) {
if len(req.Filters) > 1 || req.Filters[0].GetType() != userpb.Filter_TYPE_QUERY {
return nil, fmt.Errorf("only one query filter supported")
}
currentUser := revactx.ContextMustGetUser(ctx)
users, err := s.usermgr.FindUsers(ctx, req.Query, currentUser.GetId().GetTenantId(), req.SkipFetchingUserGroups)
users, err := s.usermgr.FindUsers(ctx, req.Filters[0].GetQuery(), currentUser.GetId().GetTenantId(), req.SkipFetchingUserGroups)
if err != nil {
res := &userpb.FindUsersResponse{
Status: status.NewInternal(ctx, "error finding users"),
@@ -180,10 +180,10 @@ type hijackLogger struct {
}
func (l *hijackLogger) Hijack() (net.Conn, *bufio.ReadWriter, error) {
h := l.responseLogger.w.(http.Hijacker)
h := l.w.(http.Hijacker)
conn, rw, err := h.Hijack()
if err == nil && l.responseLogger.status == 0 {
l.responseLogger.status = http.StatusSwitchingProtocols
if err == nil && l.status == 0 {
l.status = http.StatusSwitchingProtocols
}
return conn, rw, err
}
@@ -120,22 +120,9 @@ func (w *Webapp) ToOCMProtocol() *ocm.Protocol {
return ocmshare.NewWebappProtocol(w.URITemplate, utils.GetAppViewMode(w.ViewMode))
}
// Datatx contains the parameters for the Datatx protocol.
type Datatx struct {
SharedSecret string `json:"sharedSecret" validate:"required"`
SourceURI string `json:"srcUri" validate:"required"`
Size uint64 `json:"size" validate:"required"`
}
// ToOCMProtocol convert the protocol to a ocm Protocol struct.
func (w *Datatx) ToOCMProtocol() *ocm.Protocol {
return ocmshare.NewTransferProtocol(w.SourceURI, w.SharedSecret, w.Size)
}
var protocolImpl = map[string]reflect.Type{
"webdav": reflect.TypeOf(WebDAV{}),
"webapp": reflect.TypeOf(Webapp{}),
"datatx": reflect.TypeOf(Datatx{}),
}
// UnmarshalJSON implements the Unmarshaler interface.
@@ -304,7 +304,7 @@ func (h *DavHandler) Handler(s *svc) http.Handler {
sig := q.Get("signature")
expiration := q.Get("expiration")
// We restrict the pre-signed urls to downloads.
if sig != "" && expiration != "" && !(r.Method == http.MethodGet || r.Method == http.MethodHead) {
if sig != "" && expiration != "" && (r.Method != http.MethodGet && r.Method != http.MethodHead) {
w.WriteHeader(http.StatusUnauthorized)
return
}
@@ -372,7 +372,7 @@ func (h *DavHandler) Handler(s *svc) http.Handler {
}
fallthrough
case sRes.Status.Code == rpc.Code_CODE_NOT_FOUND:
log.Debug().Str("token", token).Interface("status", res.Status).Msg("resource not found")
log.Debug().Str("token", token).Interface("status", res.Status).Msg("Resource not found")
w.WriteHeader(http.StatusNotFound) // log the difference
return
case sRes.Status.Code == rpc.Code_CODE_UNAUTHENTICATED:
@@ -90,7 +90,7 @@ func (s *svc) handleDelete(ctx context.Context, w http.ResponseWriter, r *http.R
return http.StatusNoContent, nil
case res.Status.Code == rpc.Code_CODE_NOT_FOUND:
//lint:ignore ST1005 mimic the exact oc10 error message
return http.StatusNotFound, errors.New("Resource not found")
return http.StatusNotFound, errors.New("Resource not found") //nolint:staticcheck
case res.Status.Code == rpc.Code_CODE_PERMISSION_DENIED:
status = http.StatusForbidden
if lockID := utils.ReadPlainFromOpaque(res.Opaque, "lockid"); lockID != "" {
@@ -110,7 +110,7 @@ func (s *svc) handleDelete(ctx context.Context, w http.ResponseWriter, r *http.R
// TODO hide permission failed for users without access in every kind of request
// TODO should this be done in the driver?
//lint:ignore ST1005 mimic the exact oc10 error message
return http.StatusNotFound, errors.New("Resource not found")
return http.StatusNotFound, errors.New("Resource not found") //nolint:staticcheck
}
return status, errors.New("") // mimic the oc10 error messages which have an empty message in this case
case res.Status.Code == rpc.Code_CODE_INTERNAL && res.Status.Message == "can't delete mount path":
@@ -615,27 +615,27 @@ func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) {
lockdiscovery.WriteString("<d:prop xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\"><d:lockdiscovery><d:activelock>\n")
lockdiscovery.WriteString(" <d:locktype><d:write/></d:locktype>\n")
lockdiscovery.WriteString(" <d:lockscope><d:exclusive/></d:lockscope>\n")
lockdiscovery.WriteString(fmt.Sprintf(" <d:depth>%s</d:depth>\n", depth))
fmt.Fprintf(&lockdiscovery, " <d:depth>%s</d:depth>\n", depth)
if ld.OwnerXML != "" {
lockdiscovery.WriteString(fmt.Sprintf(" <d:owner>%s</d:owner>\n", ld.OwnerXML))
fmt.Fprintf(&lockdiscovery, " <d:owner>%s</d:owner>\n", ld.OwnerXML)
}
if ld.Duration > 0 {
timeout := ld.Duration / time.Second
lockdiscovery.WriteString(fmt.Sprintf(" <d:timeout>Second-%d</d:timeout>\n", timeout))
fmt.Fprintf(&lockdiscovery, " <d:timeout>Second-%d</d:timeout>\n", timeout)
} else {
lockdiscovery.WriteString(" <d:timeout>Infinite</d:timeout>\n")
}
if token != "" {
lockdiscovery.WriteString(fmt.Sprintf(" <d:locktoken><d:href>%s</d:href></d:locktoken>\n", prop.Escape(token)))
fmt.Fprintf(&lockdiscovery, " <d:locktoken><d:href>%s</d:href></d:locktoken>\n", prop.Escape(token))
}
if href != "" {
lockdiscovery.WriteString(fmt.Sprintf(" <d:lockroot><d:href>%s</d:href></d:lockroot>\n", prop.Escape(href)))
fmt.Fprintf(&lockdiscovery, " <d:lockroot><d:href>%s</d:href></d:lockroot>\n", prop.Escape(href))
}
if ld.OwnerName != "" {
lockdiscovery.WriteString(fmt.Sprintf(" <oc:ownername>%s</oc:ownername>\n", prop.Escape(ld.OwnerName)))
fmt.Fprintf(&lockdiscovery, " <oc:ownername>%s</oc:ownername>\n", prop.Escape(ld.OwnerName))
}
if !ld.Locktime.IsZero() {
lockdiscovery.WriteString(fmt.Sprintf(" <oc:locktime>%s</oc:locktime>\n", prop.Escape(ld.Locktime.Format(time.RFC3339))))
fmt.Fprintf(&lockdiscovery, " <oc:locktime>%s</oc:locktime>\n", prop.Escape(ld.Locktime.Format(time.RFC3339)))
}
lockdiscovery.WriteString("</d:activelock></d:lockdiscovery></d:prop>")
@@ -63,7 +63,7 @@ func (s *svc) handlePathMkcol(w http.ResponseWriter, r *http.Request, ns string)
case sr.Status.Code == rpc.Code_CODE_OK:
// https://www.rfc-editor.org/rfc/rfc4918#section-9.3.1:
// 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.
return http.StatusMethodNotAllowed, fmt.Errorf("The resource you tried to create already exists")
return http.StatusMethodNotAllowed, fmt.Errorf("The resource you tried to create already exists") //nolint:staticcheck
case sr.Status.Code == rpc.Code_CODE_ABORTED:
return http.StatusPreconditionFailed, errtypes.NewErrtypeFromStatus(sr.Status)
case sr.Status.Code != rpc.Code_CODE_NOT_FOUND:
@@ -133,7 +133,7 @@ func (s *svc) handleMkcol(ctx context.Context, w http.ResponseWriter, r *http.Re
// This should never happen because if the parent collection does not exist we should
// get a Code_CODE_FAILED_PRECONDITION. We play stupid and return what the response gave us
//lint:ignore ST1005 mimic the exact oc10 error message
return http.StatusNotFound, errors.New("Resource not found")
return http.StatusNotFound, errors.New("Resource not found") //nolint:staticcheck
case res.Status.Code == rpc.Code_CODE_PERMISSION_DENIED:
// check if user has access to parent
sRes, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{
@@ -148,7 +148,7 @@ func (s *svc) handleMkcol(ctx context.Context, w http.ResponseWriter, r *http.Re
// TODO hide permission failed for users without access in every kind of request
// TODO should this be done in the driver?
//lint:ignore ST1005 mimic the exact oc10 error message
return http.StatusNotFound, errors.New("Resource not found")
return http.StatusNotFound, errors.New("Resource not found") //nolint:staticcheck
}
return http.StatusForbidden, errors.New(sRes.Status.Message)
case res.Status.Code == rpc.Code_CODE_ABORTED:
@@ -163,7 +163,7 @@ func (s *svc) handleMkcol(ctx context.Context, w http.ResponseWriter, r *http.Re
// https://www.rfc-editor.org/rfc/rfc4918#section-9.3.1:
// 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.
//lint:ignore ST1005 mimic the exact oc10 error message
return http.StatusMethodNotAllowed, errors.New("The resource you tried to create already exists")
return http.StatusMethodNotAllowed, errors.New("The resource you tried to create already exists") //nolint:staticcheck
}
return rstatus.HTTPStatusFromCode(res.Status.Code), errtypes.NewErrtypeFromStatus(res.Status)
}
@@ -849,7 +849,7 @@ func (p *Handler) getSpaceResourceInfos(ctx context.Context, w http.ResponseWrit
}
func metadataKeysWithPrefix(prefix string, keys []string) []string {
fullKeys := []string{}
fullKeys := make([]string, 0, len(keys))
for _, key := range keys {
fullKeys = append(fullKeys, fmt.Sprintf("%s.%s", prefix, key))
}
@@ -340,7 +340,7 @@ func (s *svc) formatProppatchResponse(ctx context.Context, acceptedProps []xml.N
}
if len(acceptedProps) > 0 {
propstatBody := []prop.PropertyXML{}
propstatBody := make([]prop.PropertyXML, 0, len(acceptedProps))
for i := range acceptedProps {
propstatBody = append(propstatBody, prop.EscapedNS(acceptedProps[i].Space, acceptedProps[i].Local, ""))
}
@@ -351,7 +351,7 @@ func (s *svc) formatProppatchResponse(ctx context.Context, acceptedProps []xml.N
}
if len(removedProps) > 0 {
propstatBody := []prop.PropertyXML{}
propstatBody := make([]prop.PropertyXML, 0, len(removedProps))
for i := range removedProps {
propstatBody = append(propstatBody, prop.EscapedNS(removedProps[i].Space, removedProps[i].Local, ""))
}
@@ -24,7 +24,6 @@ import (
"net/http"
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocdav/net"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocdav/propfind"
@@ -100,7 +99,7 @@ func (s *svc) doFilterFiles(w http.ResponseWriter, r *http.Request, ff *reportFi
return
}
infos := make([]*provider.ResourceInfo, 0, len(favorites))
infos := make([]*providerv1beta1.ResourceInfo, 0, len(favorites))
for i := range favorites {
statRes, err := client.Stat(ctx, &providerv1beta1.StatRequest{Ref: &providerv1beta1.Reference{ResourceId: favorites[i]}})
if err != nil {
@@ -179,14 +178,15 @@ func readReport(r io.Reader) (rep *report, status int, err error) {
}
if v, ok := t.(xml.StartElement); ok {
if v.Name.Local == elementNameSearchFiles {
switch v.Name.Local {
case elementNameSearchFiles:
var repSF reportSearchFiles
err = decoder.DecodeElement(&repSF, &v)
if err != nil {
return nil, http.StatusBadRequest, err
}
rep.SearchFiles = &repSF
} else if v.Name.Local == elementNameFilterFiles {
case elementNameFilterFiles:
var repFF reportFilterFiles
err = decoder.DecodeElement(&repFF, &v)
if err != nil {
@@ -384,7 +384,7 @@ func (s *svc) performHTTPPush(ctx context.Context, r *http.Request, w http.Respo
defer httpDownloadRes.Body.Close()
if httpDownloadRes.StatusCode != http.StatusOK {
w.WriteHeader(httpDownloadRes.StatusCode)
return fmt.Errorf("Remote PUT returned status code %d", httpDownloadRes.StatusCode)
return fmt.Errorf("remote PUT returned status code %d", httpDownloadRes.StatusCode)
}
// send performance markers periodically every PerfMarkerResponseTime (5 seconds unless configured)
@@ -13,14 +13,11 @@ type Validator func(string) error
// ValidatorsFromConfig returns the configured Validators
func ValidatorsFromConfig(c *config.Config) []Validator {
// we always want to exclude empty names
vals := []Validator{notEmpty()}
// forbidden characters
vals = append(vals, doesNotContain(c.NameValidation.InvalidChars))
// max length
vals = append(vals, isShorterThan(c.NameValidation.MaxLength))
vals := []Validator{
notEmpty(), // we always want to exclude empty names
doesNotContain(c.NameValidation.InvalidChars), // forbidden characters
isShorterThan(c.NameValidation.MaxLength), // max length
}
return vals
}
@@ -66,7 +66,17 @@ func (h *Handler) FindSharees(w http.ResponseWriter, r *http.Request) {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error getting gateway grpc client", err)
return
}
usersRes, err := gwc.FindUsers(r.Context(), &userpb.FindUsersRequest{Query: term, SkipFetchingUserGroups: true})
usersRes, err := gwc.FindUsers(r.Context(), &userpb.FindUsersRequest{
Filters: []*userpb.Filter{
{
Type: userpb.Filter_TYPE_QUERY,
Term: &userpb.Filter_Query{
Query: term,
},
},
},
SkipFetchingUserGroups: true,
})
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error searching users", err)
return
@@ -106,7 +116,16 @@ func (h *Handler) FindSharees(w http.ResponseWriter, r *http.Request) {
}
}
groupsRes, err := gwc.FindGroups(r.Context(), &grouppb.FindGroupsRequest{Filter: term, SkipFetchingMembers: true})
groupsRes, err := gwc.FindGroups(r.Context(), &grouppb.FindGroupsRequest{
Filters: []*grouppb.Filter{
{
Type: grouppb.Filter_TYPE_QUERY,
Term: &grouppb.Filter_Query{
Query: term,
},
},
},
SkipFetchingMembers: true})
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error searching groups", err)
return
@@ -49,7 +49,6 @@ import (
"google.golang.org/protobuf/types/known/fieldmaskpb"
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
ocmv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
"github.com/jellydator/ttlcache/v2"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocs/config"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocs/response"
@@ -1305,8 +1304,8 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf
s.ItemSource = storagespace.FormatResourceID(info.Id)
s.FileSource = s.ItemSource
s.Path = path.Join("/", info.Path)
switch {
case h.sharePrefix == "/":
switch h.sharePrefix {
case "/":
s.FileTarget = info.Path
client, err := h.getClient()
if err == nil {
@@ -1627,13 +1626,13 @@ func mapState(state collaboration.ShareState) int {
return mapped
}
func mapOCMState(state ocmv1beta1.ShareState) int {
func mapOCMState(state ocm.ShareState) int {
switch state {
case ocmv1beta1.ShareState_SHARE_STATE_PENDING:
case ocm.ShareState_SHARE_STATE_PENDING:
return ocsStatePending
case ocmv1beta1.ShareState_SHARE_STATE_ACCEPTED:
case ocm.ShareState_SHARE_STATE_ACCEPTED:
return ocsStateAccepted
case ocmv1beta1.ShareState_SHARE_STATE_REJECTED:
case ocm.ShareState_SHARE_STATE_REJECTED:
return ocsStateRejected
default:
return ocsStateUnknown
@@ -1657,18 +1656,18 @@ func getStateFilter(s string) collaboration.ShareState {
return stateFilter
}
func getOCMStateFilter(s string) ocmv1beta1.ShareState {
func getOCMStateFilter(s string) ocm.ShareState {
switch s {
case "all":
return ocsStateUnknown // no filter
case "0": // accepted
return ocmv1beta1.ShareState_SHARE_STATE_ACCEPTED
return ocm.ShareState_SHARE_STATE_ACCEPTED
case "1": // pending
return ocmv1beta1.ShareState_SHARE_STATE_PENDING
return ocm.ShareState_SHARE_STATE_PENDING
case "2": // rejected
return ocmv1beta1.ShareState_SHARE_STATE_REJECTED
return ocm.ShareState_SHARE_STATE_REJECTED
default:
return ocmv1beta1.ShareState_SHARE_STATE_ACCEPTED
return ocm.ShareState_SHARE_STATE_ACCEPTED
}
}
@@ -117,11 +117,11 @@ func (h *Handler) GetUsers(w http.ResponseWriter, r *http.Request) {
}
var user *cs3identity.User
switch {
case userid == "":
switch userid {
case "":
response.WriteOCSError(w, r, response.MetaBadRequest.StatusCode, "missing username", fmt.Errorf("missing username"))
return
case userid == currentUser.Username:
case currentUser.Username:
user = currentUser
default:
// FIXME allow fetching other users info? only for admins