Skip to content

Commit 19fdcb9

Browse files
authored
Add ExpiryRange argument to ListPublicLinks, for notifying about expiry functionality (#41)
1 parent a8785bb commit 19fdcb9

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ require (
4444
github.com/go-playground/universal-translator v0.18.1 // indirect
4545
github.com/go-playground/validator/v10 v10.26.0 // indirect
4646
github.com/gofrs/uuid v4.4.0+incompatible // indirect
47-
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
47+
github.com/golang-jwt/jwt/v5 v5.2.3 // indirect
4848
github.com/golang/protobuf v1.5.4 // indirect
4949
github.com/google/uuid v1.6.0 // indirect
5050
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
@@ -67,7 +67,7 @@ require (
6767
go.step.sm/crypto v0.66.0 // indirect
6868
golang.org/x/image v0.13.0 // indirect
6969
golang.org/x/net v0.40.0 // indirect
70-
golang.org/x/sync v0.15.0 // indirect
70+
golang.org/x/sync v0.16.0 // indirect
7171
golang.org/x/sys v0.33.0 // indirect
7272
golang.org/x/text v0.26.0 // indirect
7373
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,8 @@ github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1
929929
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
930930
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
931931
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
932-
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
933-
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
932+
github.com/golang-jwt/jwt/v5 v5.2.3 h1:kkGXqQOBSDDWRhWNXTFpqGSCMyh/PLnqUvMGJPDJDs0=
933+
github.com/golang-jwt/jwt/v5 v5.2.3/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
934934
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
935935
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
936936
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
@@ -1502,8 +1502,8 @@ golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJ
15021502
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
15031503
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
15041504
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
1505-
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
1506-
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
1505+
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
1506+
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
15071507
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
15081508
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
15091509
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

share/sql/public_link.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ type PublicShareMgr struct {
5050
db *gorm.DB
5151
}
5252

53+
type ExpiryRange struct {
54+
From time.Time
55+
To time.Time
56+
}
57+
5358
func (PublicShareMgr) RevaPlugin() reva.PluginInfo {
5459
return reva.PluginInfo{
5560
ID: "grpc.services.publicshareprovider.drivers.sql",
@@ -252,7 +257,7 @@ func (m *PublicShareMgr) GetPublicShare(ctx context.Context, u *user.User, ref *
252257

253258
// List public shares that match the given filters
254259
func (m *PublicShareMgr) ListPublicShares(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, md *provider.ResourceInfo, sign bool) ([]*link.PublicShare, error) {
255-
links, err := m.ListPublicLinks(ctx, u, filters, md, sign)
260+
links, err := m.ListPublicLinks(ctx, u, filters, md, nil, sign)
256261
if err != nil {
257262
return nil, err
258263
}
@@ -308,14 +313,18 @@ func (m *PublicShareMgr) GetPublicShareByToken(ctx context.Context, token string
308313

309314
// List public links in the CERN-specific format. Used in cernboxcop.
310315
// Note: this method does not filter for orphaned or expired links!
311-
func (m *PublicShareMgr) ListPublicLinks(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, md *provider.ResourceInfo, sign bool) ([]model.PublicLink, error) {
316+
func (m *PublicShareMgr) ListPublicLinks(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, md *provider.ResourceInfo, expiry *ExpiryRange, sign bool) ([]model.PublicLink, error) {
312317
query := m.db.Model(&model.PublicLink{})
313318

314319
if u != nil {
315320
uid := conversions.FormatUserID(u.Id)
316321
query = query.Where("uid_owner = ? or uid_initiator = ?", uid, uid)
317322
}
318323

324+
if expiry != nil {
325+
query = query.Where("expiration >= ? and expiration <= ?", expiry.From, expiry.To)
326+
}
327+
319328
// Append filters
320329
m.appendLinkFiltersToQuery(query, filters)
321330

0 commit comments

Comments
 (0)