From 6dbcdccaefc86c70d4fc7276e46b2d4d9b6d13a1 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Tue, 16 May 2023 16:54:42 +0200 Subject: [PATCH 1/2] add missing expiry to shares Signed-off-by: Christian Richter --- changelog/unreleased/fix-missing-expiry.md | 6 ++++++ .../ocs/handlers/apps/sharing/shares/shares.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 changelog/unreleased/fix-missing-expiry.md diff --git a/changelog/unreleased/fix-missing-expiry.md b/changelog/unreleased/fix-missing-expiry.md new file mode 100644 index 0000000000..9c09d78552 --- /dev/null +++ b/changelog/unreleased/fix-missing-expiry.md @@ -0,0 +1,6 @@ +Enhancement: Add missing expiry date to shares + +We have added expiry dates to the shares + +https://github.com/cs3org/reva/pull/3895 +https://github.com/owncloud/ocis/issues/5442 \ No newline at end of file diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index fea5f61478..c539c62805 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -1411,6 +1411,22 @@ func (h *Handler) createCs3Share(ctx context.Context, w http.ResponseWriter, r * } } + expiry := r.PostFormValue("expireDate") + if expiry != "" { + ts, err := time.Parse("2006-01-02T15:04:05-0700", expiry) + if err != nil { + return nil, &ocsError{ + Code: response.MetaBadRequest.StatusCode, + Message: "could not parse expiry timestamp on this item", + Error: err, + } + } + req.Grant.Expiration = &types.Timestamp{ + Seconds: uint64(ts.Unix()), + Nanos: 0, + } + } + createShareResponse, err := client.CreateShare(ctx, req) if err != nil { return nil, &ocsError{ From 9305e330dee860a6b4d97dd7454ebc2b1f9a15fb Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Wed, 17 May 2023 09:41:21 +0200 Subject: [PATCH 2/2] incorporate requested changes Signed-off-by: Christian Richter --- .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index c539c62805..54babc0f21 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -1421,10 +1421,7 @@ func (h *Handler) createCs3Share(ctx context.Context, w http.ResponseWriter, r * Error: err, } } - req.Grant.Expiration = &types.Timestamp{ - Seconds: uint64(ts.Unix()), - Nanos: 0, - } + req.Grant.Expiration = utils.TimeToTS(ts) } createShareResponse, err := client.CreateShare(ctx, req)