Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Revert "Fix creator/initiator in public and user shares (cs3org#3878)"
Browse files Browse the repository at this point in the history
This reverts commit d8cc1ff.
  • Loading branch information
gmgigi96 committed May 15, 2023
1 parent b9a0fa8 commit 14b3549
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 181 deletions.
3 changes: 0 additions & 3 deletions changelog/1.24.0_2023-05-11/fix-users-shares.md

This file was deleted.

41 changes: 9 additions & 32 deletions pkg/cbox/publicshare/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"syscall"
"time"

gatewayv1beta1 "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand All @@ -39,7 +38,6 @@ import (
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/publicshare"
"github.com/cs3org/reva/pkg/publicshare/manager/registry"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/utils"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -73,9 +71,8 @@ type config struct {
}

type manager struct {
c *config
db *sql.DB
client gatewayv1beta1.GatewayAPIClient
c *config
db *sql.DB
}

func (c *config) init() {
Expand Down Expand Up @@ -121,15 +118,9 @@ func New(m map[string]interface{}) (publicshare.Manager, error) {
return nil, err
}

gw, err := pool.GetGatewayServiceClient(pool.Endpoint(c.GatewaySvc))
if err != nil {
return nil, err
}

mgr := manager{
c: c,
db: db,
client: gw,
c: c,
db: db,
}
go mgr.startJanitorRun()

Expand Down Expand Up @@ -284,11 +275,7 @@ func (m *manager) getByToken(ctx context.Context, token string, u *user.User) (*
}
return nil, "", err
}
share, err := conversions.ConvertToCS3PublicShare(ctx, m.client, s)
if err != nil {
return nil, "", err
}
return share, s.ShareWith, nil
return conversions.ConvertToCS3PublicShare(s), s.ShareWith, nil
}

func (m *manager) getByID(ctx context.Context, id *link.PublicShareId, u *user.User) (*link.PublicShare, string, error) {
Expand All @@ -301,11 +288,7 @@ func (m *manager) getByID(ctx context.Context, id *link.PublicShareId, u *user.U
}
return nil, "", err
}
share, err := conversions.ConvertToCS3PublicShare(ctx, m.client, s)
if err != nil {
return nil, "", err
}
return share, s.ShareWith, nil
return conversions.ConvertToCS3PublicShare(s), s.ShareWith, nil
}

func (m *manager) GetPublicShare(ctx context.Context, u *user.User, ref *link.PublicShareReference, sign bool) (*link.PublicShare, error) {
Expand Down Expand Up @@ -435,16 +418,13 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
if err := rows.Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Token, &s.Expiration, &s.ShareName, &s.ID, &s.STime, &s.Permissions, &s.Quicklink, &s.Description); err != nil {
continue
}
cs3Share, err := conversions.ConvertToCS3PublicShare(ctx, m.client, s)
if err != nil {
return nil, err
}
cs3Share := conversions.ConvertToCS3PublicShare(s)
if expired(cs3Share) {
_ = m.cleanupExpiredShares()
} else {
if cs3Share.PasswordProtected && sign {
if err := publicshare.AddSignature(cs3Share, s.ShareWith); err != nil {
continue
return nil, err
}
}
shares = append(shares, cs3Share)
Expand Down Expand Up @@ -501,10 +481,7 @@ func (m *manager) GetPublicShareByToken(ctx context.Context, token string, auth
}
return nil, err
}
cs3Share, err := conversions.ConvertToCS3PublicShare(ctx, m.client, s)
if err != nil {
return nil, err
}
cs3Share := conversions.ConvertToCS3PublicShare(s)
if expired(cs3Share) {
if err := m.cleanupExpiredShares(); err != nil {
return nil, err
Expand Down
53 changes: 10 additions & 43 deletions pkg/cbox/share/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"strings"
"time"

gatewayv1beta1 "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down Expand Up @@ -72,9 +71,8 @@ type config struct {
}

type mgr struct {
c *config
db *sql.DB
client gatewayv1beta1.GatewayAPIClient
c *config
db *sql.DB
}

// New returns a new share manager.
Expand All @@ -90,15 +88,9 @@ func New(m map[string]interface{}) (share.Manager, error) {
return nil, err
}

gw, err := pool.GetGatewayServiceClient(pool.Endpoint(c.GatewaySvc))
if err != nil {
return nil, err
}

return &mgr{
c: c,
db: db,
client: gw,
c: c,
db: db,
}, nil
}

Expand Down Expand Up @@ -197,11 +189,7 @@ func (m *mgr) getByID(ctx context.Context, id *collaboration.ShareId, checkOwner
}
return nil, err
}
share, err := conversions.ConvertToCS3Share(ctx, m.client, s)
if err != nil {
return nil, err
}
return share, nil
return conversions.ConvertToCS3Share(s), nil
}

func (m *mgr) getByKey(ctx context.Context, key *collaboration.ShareKey, checkOwner bool) (*collaboration.Share, error) {
Expand All @@ -222,11 +210,7 @@ func (m *mgr) getByKey(ctx context.Context, key *collaboration.ShareKey, checkOw
}
return nil, err
}
share, err := conversions.ConvertToCS3Share(ctx, m.client, s)
if err != nil {
return nil, err
}
return share, nil
return conversions.ConvertToCS3Share(s), nil
}

func (m *mgr) GetShare(ctx context.Context, ref *collaboration.ShareReference) (*collaboration.Share, error) {
Expand Down Expand Up @@ -466,11 +450,7 @@ func (m *mgr) ListShares(ctx context.Context, filters []*collaboration.Filter) (
if err := rows.Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.ID, &s.STime, &s.Permissions, &s.ShareType); err != nil {
continue
}
share, err := conversions.ConvertToCS3Share(ctx, m.client, s)
if err != nil {
continue
}
shares = append(shares, share)
shares = append(shares, conversions.ConvertToCS3Share(s))
}
if err = rows.Err(); err != nil {
return nil, err
Expand Down Expand Up @@ -523,11 +503,7 @@ func (m *mgr) ListReceivedShares(ctx context.Context, filters []*collaboration.F
if err := rows.Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.ID, &s.STime, &s.Permissions, &s.ShareType, &s.State); err != nil {
continue
}
share, err := conversions.ConvertToCS3ReceivedShare(ctx, m.client, s)
if err != nil {
continue
}
shares = append(shares, share)
shares = append(shares, conversions.ConvertToCS3ReceivedShare(s))
}
if err = rows.Err(); err != nil {
return nil, err
Expand Down Expand Up @@ -562,11 +538,7 @@ func (m *mgr) getReceivedByID(ctx context.Context, id *collaboration.ShareId) (*
}
return nil, err
}
share, err := conversions.ConvertToCS3ReceivedShare(ctx, m.client, s)
if err != nil {
return nil, err
}
return share, nil
return conversions.ConvertToCS3ReceivedShare(s), nil
}

func (m *mgr) getReceivedByKey(ctx context.Context, key *collaboration.ShareKey) (*collaboration.ReceivedShare, error) {
Expand Down Expand Up @@ -597,12 +569,7 @@ func (m *mgr) getReceivedByKey(ctx context.Context, key *collaboration.ShareKey)
}
return nil, err
}

share, err := conversions.ConvertToCS3ReceivedShare(ctx, m.client, s)
if err != nil {
return nil, err
}
return share, nil
return conversions.ConvertToCS3ReceivedShare(s), nil
}

func (m *mgr) GetReceivedShare(ctx context.Context, ref *collaboration.ShareReference) (*collaboration.ReceivedShare, error) {
Expand Down
Loading

0 comments on commit 14b3549

Please sign in to comment.