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

Commit

Permalink
Add description to public links + internal public links (cs3org#3305)
Browse files Browse the repository at this point in the history
* use update go cs3apis (temporary)

* Add description in db public link

* add description in the sql driver

* update go cs3apis

* add description in xml response for public links

* create and update a public link with description

* hide tags by description in sql driver

* update cs3apis

* add description during creation

* updated cli cmd for public share description

* fix linting

* fix query to hide tags

* add changelog

* add option to hide public shares

* updated go-cs3apis
  • Loading branch information
gmgigi96 authored Oct 7, 2022
1 parent 1e4948b commit 1bfb714
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 35 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/publiclink-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Add description to public link

https://github.com/cs3org/reva/pull/3305
10 changes: 7 additions & 3 deletions cmd/reva/public-share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ func publicShareCreateCommand() *command {
cmd.Description = func() string { return "create a public share" }
cmd.Usage = func() string { return "Usage: public-share-create [-flags] <path>" }
rol := cmd.String("rol", "viewer", "the permission for the share (viewer or editor)")
description := cmd.String("description", "", "the description for the share")
internal := cmd.Bool("internal", false, "mark the public share as internal")

cmd.ResetFlags = func() {
*rol = "viewer"
*rol, *description, *internal = "viewer", "", false
}

cmd.Action = func(w ...io.Writer) error {
Expand Down Expand Up @@ -78,6 +80,8 @@ func publicShareCreateCommand() *command {
shareRequest := &link.CreatePublicShareRequest{
ResourceInfo: res.Info,
Grant: grant,
Description: *description,
Internal: *internal,
}

shareRes, err := client.CreatePublicShare(ctx, shareRequest)
Expand All @@ -91,11 +95,11 @@ func publicShareCreateCommand() *command {

t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Token", "Expiration", "Created", "Updated"})
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Token", "Expiration", "Created", "Updated", "Description"})

s := shareRes.Share
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0), s.Description},
})
t.Render()

Expand Down
4 changes: 2 additions & 2 deletions cmd/reva/public-share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ func publicShareListCommand() *command {
if len(w) == 0 {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Token", "Expiration", "Created", "Updated"})
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Token", "Expiration", "Created", "Updated", "Description"})

for _, s := range shareRes.Share {
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0), s.Description},
})
}
t.Render()
Expand Down
37 changes: 29 additions & 8 deletions cmd/reva/public-share-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ func publicShareUpdateCommand() *command {
cmd.Description = func() string { return "update a public share" }
cmd.Usage = func() string { return "Usage: public-share-update [-flags] <share_id>" }
rol := cmd.String("rol", "viewer", "the permission for the share (viewer or editor)")
description := cmd.String("description", "", "the description for the share")

cmd.ResetFlags = func() {
*rol = "viewer"
*rol, *description = "viewer", ""
}
cmd.Action = func(w ...io.Writer) error {
if cmd.NArg() < 1 {
Expand All @@ -59,7 +60,9 @@ func publicShareUpdateCommand() *command {
return err
}

shareRequest := &link.UpdatePublicShareRequest{
var updates []*link.UpdatePublicShareRequest

updates = append(updates, &link.UpdatePublicShareRequest{
Ref: &link.PublicShareReference{
Spec: &link.PublicShareReference_Id{
Id: &link.PublicShareId{
Expand All @@ -75,15 +78,33 @@ func publicShareUpdateCommand() *command {
},
},
},
}
})

shareRes, err := shareClient.UpdatePublicShare(ctx, shareRequest)
if err != nil {
return err
if *description != "" {
updates = append(updates, &link.UpdatePublicShareRequest{
Ref: &link.PublicShareReference{
Spec: &link.PublicShareReference_Id{
Id: &link.PublicShareId{
OpaqueId: id,
},
},
},
Update: &link.UpdatePublicShareRequest_Update{
Type: link.UpdatePublicShareRequest_Update_TYPE_DESCRIPTION,
Description: *description,
},
})
}

if shareRes.Status.Code != rpc.Code_CODE_OK {
return formatError(shareRes.Status)
for _, u := range updates {
shareRes, err := shareClient.UpdatePublicShare(ctx, u)
if err != nil {
return err
}

if shareRes.Status.Code != rpc.Code_CODE_OK {
return formatError(shareRes.Status)
}
}

fmt.Println("OK")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/cheggaaa/pb v1.0.29
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e
github.com/cs3org/go-cs3apis v0.0.0-20220929083235-bb0b1a236d6c
github.com/cs3org/go-cs3apis v0.0.0-20221004162747-f20ee4756d90
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8
github.com/dgraph-io/ristretto v0.1.0
github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJffz4pz0o1WuQxJ28+5x5JgaHD8=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20220330081745-2ad58f5932b9 h1:SuPu5Mc2mpz+J059XML+cMd0i5FZR4t/kROS3SaIsnU=
github.com/cs3org/go-cs3apis v0.0.0-20220330081745-2ad58f5932b9/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20220719130120-361e9f987d64 h1:cFnankJOCWndnOns4sKRG7yzH61ammK2Am6rEGWCK40=
github.com/cs3org/go-cs3apis v0.0.0-20220719130120-361e9f987d64/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20220929083235-bb0b1a236d6c h1:b+YTmOGlf43mnF8MzO0fsy8/Ho8JLu44Iq5Y0fKLJMM=
github.com/cs3org/go-cs3apis v0.0.0-20220929083235-bb0b1a236d6c/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20221004162747-f20ee4756d90 h1:zYg2UzwpChLgXktwt7MJEMv46GQPtluifRnynkSw80Y=
github.com/cs3org/go-cs3apis v0.0.0-20221004162747-f20ee4756d90/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
Expand Down Expand Up @@ -287,6 +283,8 @@ github.com/gdexlab/go-render v1.0.1/go.mod h1:wRi5nW2qfjiGj4mPukH4UV0IknS1cHD4Vg
github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/gmgigi96/go-cs3apis v0.0.0-20221004074314-b2292f6a794c h1:mC9jwnDK3weg0S3md2euO0iIvlD33JE/MsFQGaZ/zX0=
github.com/gmgigi96/go-cs3apis v0.0.0-20221004074314-b2292f6a794c/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/go-acme/lego/v4 v4.4.0/go.mod h1:l3+tFUFZb590dWcqhWZegynUthtaHJbG2fevUpoOOE0=
github.com/go-asn1-ber/asn1-ber v1.5.4 h1:vXT6d/FNDiELJnLb6hGNa309LMsrCoYFvpwHDF0+Y1A=
github.com/go-asn1-ber/asn1-ber v1.5.4/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *service) CreatePublicShare(ctx context.Context, req *link.CreatePublicS
log.Error().Msg("error getting user from context")
}

share, err := s.sm.CreatePublicShare(ctx, u, req.ResourceInfo, req.Grant)
share, err := s.sm.CreatePublicShare(ctx, u, req.ResourceInfo, req.Grant, req.Description, req.Internal)
if err != nil {
log.Debug().Err(err).Str("createShare", "shares").Msg("error connecting to storage provider")
}
Expand Down
3 changes: 3 additions & 0 deletions internal/http/services/owncloud/ocs/conversions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ type ShareData struct {
// PasswordProtected represents a public share is password protected
// PasswordProtected bool `json:"password_protected,omitempty" xml:"password_protected,omitempty"`
Quicklink bool `json:"quicklink,omitempty" xml:"quicklink,omitempty"`
// Description of the public share
Description string `json:"description" xml:"description"`
}

// ShareeData holds share recipient search results
Expand Down Expand Up @@ -217,6 +219,7 @@ func PublicShare2ShareData(share *link.PublicShare, r *http.Request, publicURL s
UIDOwner: LocalUserIDToString(share.Creator),
UIDFileOwner: LocalUserIDToString(share.Owner),
Quicklink: share.Quicklink,
Description: share.Description,
}
if share.Id != nil {
sd.ID = share.Id.OpaqueId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ func (h *Handler) createPublicLinkShare(w http.ResponseWriter, r *http.Request,
newPermissions = conversions.RoleFromOCSPermissions(permissions).CS3ResourcePermissions()
}

internal, _ := strconv.ParseBool(r.FormValue("internal"))

req := link.CreatePublicShareRequest{
ResourceInfo: statInfo,
Grant: &link.Grant{
Expand All @@ -118,6 +120,8 @@ func (h *Handler) createPublicLinkShare(w http.ResponseWriter, r *http.Request,
},
Password: r.FormValue("password"),
},
Description: r.FormValue("description"),
Internal: internal,
}

expireTimeString, ok := r.Form["expireDate"]
Expand Down Expand Up @@ -359,6 +363,17 @@ func (h *Handler) updatePublicShare(w http.ResponseWriter, r *http.Request, shar
})
}

// Description
description, ok := r.Form["description"]
if ok {
updatesFound = true
logger.Info().Str("shares", "update").Msg("description updated")
updates = append(updates, &link.UpdatePublicShareRequest_Update{
Type: link.UpdatePublicShareRequest_Update_TYPE_DESCRIPTION,
Description: description[0],
})
}

publicShare := before.Share

// Updates are atomical. See: https://github.com/cs3org/cs3apis/pull/67#issuecomment-617651428 so in order to get the latest updated version
Expand Down
25 changes: 14 additions & 11 deletions pkg/cbox/publicshare/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func New(m map[string]interface{}) (publicshare.Manager, error) {
return &mgr, nil
}

func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *provider.ResourceInfo, g *link.Grant) (*link.PublicShare, error) {
func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *provider.ResourceInfo, g *link.Grant, description string, internal bool) (*link.PublicShare, error) {

tkn := utils.RandString(15)
now := time.Now().Unix()
Expand Down Expand Up @@ -156,8 +156,8 @@ func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *pr
fileSource = 0
}

query := "insert into oc_share set share_type=?,uid_owner=?,uid_initiator=?,item_type=?,fileid_prefix=?,item_source=?,file_source=?,permissions=?,stime=?,token=?,share_name=?,quicklink=?"
params := []interface{}{publicShareType, owner, creator, itemType, prefix, itemSource, fileSource, permissions, now, tkn, displayName, quicklink}
query := "insert into oc_share set share_type=?,uid_owner=?,uid_initiator=?,item_type=?,fileid_prefix=?,item_source=?,file_source=?,permissions=?,stime=?,token=?,share_name=?,quicklink=?,description=?,internal=?"
params := []interface{}{publicShareType, owner, creator, itemType, prefix, itemSource, fileSource, permissions, now, tkn, displayName, quicklink, description, internal}

var passwordProtected bool
password := g.Password
Expand Down Expand Up @@ -206,6 +206,7 @@ func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *pr
Expiration: g.Expiration,
DisplayName: displayName,
Quicklink: quicklink,
Description: description,
}, nil
}

Expand Down Expand Up @@ -234,6 +235,8 @@ func (m *manager) UpdatePublicShare(ctx context.Context, u *user.User, req *link
}
paramsMap["share_with"] = h
}
case link.UpdatePublicShareRequest_Update_TYPE_DESCRIPTION:
paramsMap["description"] = req.Update.GetDescription()
default:
return nil, fmt.Errorf("invalid update type: %v", req.GetUpdate().GetType())
}
Expand Down Expand Up @@ -267,8 +270,8 @@ func (m *manager) UpdatePublicShare(ctx context.Context, u *user.User, req *link

func (m *manager) getByToken(ctx context.Context, token string, u *user.User) (*link.PublicShare, string, error) {
s := conversions.DBShare{Token: token}
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND share_type=? AND token=?"
if err := m.db.QueryRow(query, publicShareType, token).Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Expiration, &s.ShareName, &s.ID, &s.STime, &s.Permissions, &s.Quicklink); err != nil {
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink, description FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND share_type=? AND token=?"
if err := m.db.QueryRow(query, publicShareType, token).Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Expiration, &s.ShareName, &s.ID, &s.STime, &s.Permissions, &s.Quicklink, &s.Description); err != nil {
if err == sql.ErrNoRows {
return nil, "", errtypes.NotFound(token)
}
Expand All @@ -280,8 +283,8 @@ func (m *manager) getByToken(ctx context.Context, token string, u *user.User) (*
func (m *manager) getByID(ctx context.Context, id *link.PublicShareId, u *user.User) (*link.PublicShare, string, error) {
uid := conversions.FormatUserID(u.Id)
s := conversions.DBShare{ID: id.OpaqueId}
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(token,'') as token, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, stime, permissions, quicklink FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND share_type=? AND id=? AND (uid_owner=? OR uid_initiator=?)"
if err := m.db.QueryRow(query, publicShareType, id.OpaqueId, uid, uid).Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Token, &s.Expiration, &s.ShareName, &s.STime, &s.Permissions, &s.Quicklink); err != nil {
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(token,'') as token, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, stime, permissions, quicklink, description FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND share_type=? AND id=? AND (uid_owner=? OR uid_initiator=?)"
if err := m.db.QueryRow(query, publicShareType, id.OpaqueId, uid, uid).Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Token, &s.Expiration, &s.ShareName, &s.STime, &s.Permissions, &s.Quicklink, &s.Description); err != nil {
if err == sql.ErrNoRows {
return nil, "", errtypes.NotFound(id.OpaqueId)
}
Expand Down Expand Up @@ -324,7 +327,7 @@ func (m *manager) GetPublicShare(ctx context.Context, u *user.User, ref *link.Pu
}

func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, md *provider.ResourceInfo, sign bool) ([]*link.PublicShare, error) {
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(token,'') as token, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND (share_type=?)"
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(token,'') as token, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink, description FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND (share_type=?) AND internal=false"
var resourceFilters, ownerFilters, creatorFilters string
var resourceParams, ownerParams, creatorParams []interface{}
params := []interface{}{publicShareType}
Expand Down Expand Up @@ -382,7 +385,7 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
var s conversions.DBShare
shares := []*link.PublicShare{}
for rows.Next() {
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); err != nil {
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 := conversions.ConvertToCS3PublicShare(s)
Expand Down Expand Up @@ -441,8 +444,8 @@ func (m *manager) RevokePublicShare(ctx context.Context, u *user.User, ref *link

func (m *manager) GetPublicShareByToken(ctx context.Context, token string, auth *link.PublicShareAuthentication, sign bool) (*link.PublicShare, error) {
s := conversions.DBShare{Token: token}
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink FROM oc_share WHERE share_type=? AND token=?"
if err := m.db.QueryRow(query, publicShareType, token).Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Expiration, &s.ShareName, &s.ID, &s.STime, &s.Permissions, &s.Quicklink); err != nil {
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink, description FROM oc_share WHERE share_type=? AND token=?"
if err := m.db.QueryRow(query, publicShareType, token).Scan(&s.UIDOwner, &s.UIDInitiator, &s.ShareWith, &s.Prefix, &s.ItemSource, &s.ItemType, &s.Expiration, &s.ShareName, &s.ID, &s.STime, &s.Permissions, &s.Quicklink, &s.Description); err != nil {
if err == sql.ErrNoRows {
return nil, errtypes.NotFound(token)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cbox/utils/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type DBShare struct {
FileTarget string
State int
Quicklink bool
Description string
}

// FormatGrantee formats a CS3API grantee to a string
Expand Down Expand Up @@ -252,5 +253,6 @@ func ConvertToCS3PublicShare(s DBShare) *link.PublicShare {
Ctime: ts,
Mtime: ts,
Quicklink: s.Quicklink,
Description: s.Description,
}
}
Loading

0 comments on commit 1bfb714

Please sign in to comment.