Skip to content

Commit

Permalink
Merge pull request #8954 from fschade/graph-permission-c-time
Browse files Browse the repository at this point in the history
enhancement: inject the creation time into sharing permissions
  • Loading branch information
JammingBen committed Apr 29, 2024
2 parents 8b772fc + f34bb51 commit 57b63a3
Show file tree
Hide file tree
Showing 14 changed files with 1,807 additions and 22 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/graph-permission-created-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Graph permission created date time

We've added the created date time to graph permission objects.

https://github.com/owncloud/ocis/pull/8954
https://github.com/owncloud/ocis/issues/8749
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ require (
github.com/onsi/gomega v1.33.0
github.com/open-policy-agent/opa v0.64.1
github.com/orcaman/concurrent-map v1.0.0
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240130152355-ac663a9002a1
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240425090020-dba6d1507c38
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.9
github.com/prometheus/client_golang v1.19.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,8 @@ github.com/oracle/oci-go-sdk v24.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35uk
github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HDbW65HOY=
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240130152355-ac663a9002a1 h1:QLEERCsKv9VhkQaCP5zMEPdAqJLp/iuyogrg/eTfISg=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240130152355-ac663a9002a1/go.mod h1:v2aAl5IwEI8t+GmcWvBd+bvJMYp9Vf1hekLuRf0UnEs=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240425090020-dba6d1507c38 h1:Ld9bPh0c4y1H22mhiWZBw4AoupWjg8L0WLKX0hfbJho=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240425090020-dba6d1507c38/go.mod h1:yXI+rmE8yYx+ZsGVrnCpprw/gZMcxjwntnX2y2+VKxY=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
Expand Down
14 changes: 12 additions & 2 deletions services/graph/pkg/service/v0/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
libregraph "github.com/owncloud/libre-graph-api-go"
"google.golang.org/protobuf/types/known/fieldmaskpb"

"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/v2/pkg/share"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
libregraph "github.com/owncloud/libre-graph-api-go"
"google.golang.org/protobuf/types/known/fieldmaskpb"

"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
Expand Down Expand Up @@ -223,6 +224,11 @@ func (g BaseGraphService) libreGraphPermissionFromCS3PublicShare(createdLink *li
perm.SetExpirationDateTime(cs3TimestampToTime(createdLink.GetExpiration()).UTC())
}

// set cTime
if createdLink.GetCtime() != nil {
perm.SetCreatedDateTime(cs3TimestampToTime(createdLink.GetCtime()).UTC())
}

perm.SetHasPassword(createdLink.GetPasswordProtected())

return perm, nil
Expand Down Expand Up @@ -372,6 +378,10 @@ func (g BaseGraphService) cs3UserShareToPermission(ctx context.Context, share *c
if share.GetExpiration() != nil {
perm.SetExpirationDateTime(cs3TimestampToTime(share.GetExpiration()))
}
// set cTime
if share.GetCtime() != nil {
perm.SetCreatedDateTime(cs3TimestampToTime(share.GetCtime()))
}
role := unifiedrole.CS3ResourcePermissionsToUnifiedRole(
*share.GetPermissions().GetPermissions(),
roleCondition,
Expand Down
4 changes: 4 additions & 0 deletions services/graph/pkg/service/v0/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ func cs3ReceivedShareToLibreGraphPermissions(ctx context.Context, logger *log.Lo
permission.SetExpirationDateTime(cs3TimestampToTime(expiration))
}

if cTime := receivedShare.GetShare().GetCtime(); cTime != nil {
permission.SetCreatedDateTime(cs3TimestampToTime(cTime))
}

if permissionSet := receivedShare.GetShare().GetPermissions().GetPermissions(); permissionSet != nil {
condition, err := roleConditionForResourceType(resourceInfo)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions vendor/github.com/owncloud/libre-graph-api-go/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

251 changes: 251 additions & 0 deletions vendor/github.com/owncloud/libre-graph-api-go/api_drive_item.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57b63a3

Please sign in to comment.