@@ -50,6 +50,7 @@ class FilesPlugin extends ServerPlugin {
5050 public const OCM_SHARE_PERMISSIONS_PROPERTYNAME = '{http://open-cloud-mesh.org/ns}share-permissions ' ;
5151 public const SHARE_ATTRIBUTES_PROPERTYNAME = '{http://nextcloud.org/ns}share-attributes ' ;
5252 public const DOWNLOADURL_PROPERTYNAME = '{http://owncloud.org/ns}downloadURL ' ;
53+ public const DOWNLOADURL_EXPIRATION_PROPERTYNAME = '{http://nextcloud.org/ns}download-url-expiration ' ;
5354 public const SIZE_PROPERTYNAME = '{http://owncloud.org/ns}size ' ;
5455 public const GETETAG_PROPERTYNAME = '{DAV:}getetag ' ;
5556 public const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified ' ;
@@ -120,6 +121,7 @@ public function initialize(Server $server) {
120121 $ server ->protectedProperties [] = self ::SHARE_ATTRIBUTES_PROPERTYNAME ;
121122 $ server ->protectedProperties [] = self ::SIZE_PROPERTYNAME ;
122123 $ server ->protectedProperties [] = self ::DOWNLOADURL_PROPERTYNAME ;
124+ $ server ->protectedProperties [] = self ::DOWNLOADURL_EXPIRATION_PROPERTYNAME ;
123125 $ server ->protectedProperties [] = self ::OWNER_ID_PROPERTYNAME ;
124126 $ server ->protectedProperties [] = self ::OWNER_DISPLAY_NAME_PROPERTYNAME ;
125127 $ server ->protectedProperties [] = self ::CHECKSUMS_PROPERTYNAME ;
@@ -471,19 +473,30 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
471473 }
472474
473475 if ($ node instanceof File) {
474- $ propFind ->handle (self ::DOWNLOADURL_PROPERTYNAME , function () use ($ node ) {
476+ $ requestProperties = $ propFind ->getRequestedProperties ();
477+
478+ if (in_array (self ::DOWNLOADURL_PROPERTYNAME , $ requestProperties , true )
479+ || in_array (self ::DOWNLOADURL_EXPIRATION_PROPERTYNAME , $ requestProperties , true )) {
475480 try {
476481 $ directDownloadUrl = $ node ->getDirectDownload ();
477- if (isset ($ directDownloadUrl ['url ' ])) {
482+ } catch (StorageNotAvailableException |ForbiddenException ) {
483+ $ directDownloadUrl = null ;
484+ }
485+
486+ $ propFind ->handle (self ::DOWNLOADURL_PROPERTYNAME , function () use ($ node , $ directDownloadUrl ) {
487+ if ($ directDownloadUrl && isset ($ directDownloadUrl ['url ' ])) {
478488 return $ directDownloadUrl ['url ' ];
479489 }
480- } catch (StorageNotAvailableException $ e ) {
481490 return false ;
482- } catch (ForbiddenException $ e ) {
491+ });
492+
493+ $ propFind ->handle (self ::DOWNLOADURL_EXPIRATION_PROPERTYNAME , function () use ($ node , $ directDownloadUrl ) {
494+ if ($ directDownloadUrl && isset ($ directDownloadUrl ['expiration ' ])) {
495+ return $ directDownloadUrl ['expiration ' ];
496+ }
483497 return false ;
484- }
485- return false ;
486- });
498+ });
499+ }
487500
488501 $ propFind ->handle (self ::CHECKSUMS_PROPERTYNAME , function () use ($ node ) {
489502 $ checksum = $ node ->getChecksum ();
0 commit comments