@@ -645,6 +645,16 @@ public function createShare(
645645 $ share = $ this ->setShareAttributes ($ share , $ attributes );
646646 }
647647
648+ //Expire date
649+ if ($ expireDate !== '' ) {
650+ try {
651+ $ expireDate = $ this ->parseDate ($ expireDate );
652+ $ share ->setExpirationDate ($ expireDate );
653+ } catch (\Exception $ e ) {
654+ throw new OCSNotFoundException ($ this ->l ->t ('Invalid date, date format must be YYYY-MM-DD ' ));
655+ }
656+ }
657+
648658 $ share ->setSharedBy ($ this ->currentUser );
649659 $ this ->checkInheritedAttributes ($ share );
650660
@@ -731,15 +741,6 @@ public function createShare(
731741
732742 $ share ->setSharedWith ($ shareWith );
733743 $ share ->setPermissions ($ permissions );
734- if ($ expireDate !== '' ) {
735- try {
736- $ expireDate = $ this ->parseDate ($ expireDate );
737- $ share ->setExpirationDate ($ expireDate );
738- } catch (\Exception $ e ) {
739- throw new OCSNotFoundException ($ this ->l ->t ('Invalid date, date format must be YYYY-MM-DD ' ));
740- }
741- }
742-
743744 $ share ->setSharedWithDisplayName ($ this ->getCachedFederatedDisplayName ($ shareWith , false ));
744745 } elseif ($ shareType === IShare::TYPE_REMOTE_GROUP ) {
745746 if (!$ this ->shareManager ->outgoingServer2ServerGroupSharesAllowed ()) {
@@ -752,14 +753,6 @@ public function createShare(
752753
753754 $ share ->setSharedWith ($ shareWith );
754755 $ share ->setPermissions ($ permissions );
755- if ($ expireDate !== '' ) {
756- try {
757- $ expireDate = $ this ->parseDate ($ expireDate );
758- $ share ->setExpirationDate ($ expireDate );
759- } catch (\Exception $ e ) {
760- throw new OCSNotFoundException ($ this ->l ->t ('Invalid date, date format must be YYYY-MM-DD ' ));
761- }
762- }
763756 } elseif ($ shareType === IShare::TYPE_CIRCLE ) {
764757 if (!\OC ::$ server ->getAppManager ()->isEnabledForUser ('circles ' ) || !class_exists ('\OCA\Circles\ShareByCircleProvider ' )) {
765758 throw new OCSNotFoundException ($ this ->l ->t ('You cannot share to a Circle if the app is not enabled ' ));
@@ -795,16 +788,6 @@ public function createShare(
795788 throw new OCSBadRequestException ($ this ->l ->t ('Unknown share type ' ));
796789 }
797790
798- //Expire date
799- if ($ expireDate !== '' ) {
800- try {
801- $ expireDate = $ this ->parseDate ($ expireDate );
802- $ share ->setExpirationDate ($ expireDate );
803- } catch (\Exception $ e ) {
804- throw new OCSNotFoundException ($ this ->l ->t ('Invalid date, date format must be YYYY-MM-DD ' ));
805- }
806- }
807-
808791 $ share ->setShareType ($ shareType );
809792
810793 if ($ note !== '' ) {
0 commit comments