@@ -807,14 +807,15 @@ protected function shareWithTeam(string $shareWith, Node $fileSource, string $fi
807807 * @throws \OCP\Files\NotFoundException
808808 */
809809 public function unShare (IShare $ share ) {
810- if (in_array ($ share ->getNodeType (), ['file ' , 'folder ' ], true ) && !$ this ->isDeletedNode ($ share ->getShareOwner (), $ share ->getNodeId ())) {
811- if ($ share ->getShareType () === IShare::TYPE_USER ) {
812- $ this ->unshareFromUser ($ share );
813- } elseif ($ share ->getShareType () === IShare::TYPE_GROUP ) {
814- $ this ->unshareFromGroup ($ share );
815- } elseif ($ share ->getShareType () === IShare::TYPE_LINK ) {
816- $ this ->unshareLink ($ share );
817- }
810+ if (!in_array ($ share ->getNodeType (), ['file ' , 'folder ' ], true ) || $ this ->isDeletedNode ($ share ->getShareOwner (), $ share ->getNodeId ())) {
811+ return ;
812+ }
813+ if ($ share ->getShareType () === IShare::TYPE_USER ) {
814+ $ this ->unshareFromUser ($ share );
815+ } elseif ($ share ->getShareType () === IShare::TYPE_GROUP ) {
816+ $ this ->unshareFromGroup ($ share );
817+ } elseif ($ share ->getShareType () === IShare::TYPE_LINK ) {
818+ $ this ->unshareLink ($ share );
818819 }
819820 }
820821
@@ -825,12 +826,13 @@ public function unShare(IShare $share) {
825826 * @throws \OCP\Files\NotFoundException
826827 */
827828 public function unShareSelf (IShare $ share ) {
828- if (in_array ($ share ->getNodeType (), ['file ' , 'folder ' ], true )) {
829- if ($ share ->getShareType () === IShare::TYPE_GROUP ) {
830- $ this ->unshareFromSelfGroup ($ share );
831- } elseif ($ share ->getShareType () === IShare::TYPE_USER ) {
832- $ this ->unshareFromUser ($ share );
833- }
829+ if (!in_array ($ share ->getNodeType (), ['file ' , 'folder ' ], true )) {
830+ return ;
831+ }
832+ if ($ share ->getShareType () === IShare::TYPE_GROUP ) {
833+ $ this ->unshareFromSelfGroup ($ share );
834+ } elseif ($ share ->getShareType () === IShare::TYPE_USER ) {
835+ $ this ->unshareFromUser ($ share );
834836 }
835837 }
836838
@@ -1097,51 +1099,51 @@ protected function reshareNotificationForSharer(string $owner, string $subject,
10971099 */
10981100 protected function shareNotificationForOriginalOwners (string $ sharedBy , string $ subject , string $ shareWith , Node $ fileSource ) {
10991101 $ mount = $ fileSource ->getMountPoint ();
1100- if ($ mount instanceof SharedMount) {
1101- $ sourceShare = $ mount ->getShare ();
1102+ if (!$ mount instanceof SharedMount) {
1103+ return ;
1104+ }
11021105
1103- $ fileId = $ fileSource ->getId ();
1106+ $ sourceShare = $ mount ->getShare ();
1107+ $ fileId = $ fileSource ->getId ();
11041108
1105- if ($ sourceShare ->getShareOwner () !== $ sharedBy ) {
1106- $ owner = $ sourceShare ->getShareOwner ();
1107- try {
1108- $ ownerNode = $ this ->rootFolder ->getUserFolder ($ owner )->getFirstNodeById ($ fileId );
1109- } catch (NotFoundException ) {
1110- return ;
1111- }
1112- if ($ ownerNode === null ) {
1113- return ;
1114- }
1115- $ this ->reshareNotificationForSharer (
1116- $ owner ,
1117- $ subject ,
1118- $ shareWith ,
1119- $ fileId ,
1120- $ this ->getUserRelativePath ($ owner , $ ownerNode ->getPath ()),
1121- $ fileSource instanceof File,
1122- );
1109+ if ($ sourceShare ->getShareOwner () !== $ sharedBy ) {
1110+ $ owner = $ sourceShare ->getShareOwner ();
1111+ try {
1112+ $ ownerNode = $ this ->rootFolder ->getUserFolder ($ owner )->getFirstNodeById ($ fileId );
1113+ } catch (NotFoundException ) {
1114+ return ;
11231115 }
1116+ if ($ ownerNode === null ) {
1117+ return ;
1118+ }
1119+ $ this ->reshareNotificationForSharer (
1120+ $ owner ,
1121+ $ subject ,
1122+ $ shareWith ,
1123+ $ fileId ,
1124+ $ this ->getUserRelativePath ($ owner , $ ownerNode ->getPath ()),
1125+ $ fileSource instanceof File,
1126+ );
1127+ }
11241128
1125- if ($ sourceShare ->getSharedBy () && $ sourceShare ->getSharedBy () !== $ sharedBy && $ sourceShare ->getShareOwner () !== $ sourceShare ->getSharedBy ()) {
1126- $ sharer = $ sourceShare ->getSharedBy ();
1127- try {
1128- $ sharerNode = $ this ->rootFolder ->getUserFolder ($ sharer )->getFirstNodeById ($ fileId );
1129- } catch (NotFoundException ) {
1130- return ;
1131- }
1132- if ($ sharerNode === null ) {
1133- return ;
1134- }
1135-
1136- $ this ->reshareNotificationForSharer (
1137- $ sharer ,
1138- $ subject ,
1139- $ shareWith ,
1140- $ fileId ,
1141- $ this ->getUserRelativePath ($ sharer , $ sharerNode ->getPath ()),
1142- $ fileSource instanceof File,
1143- );
1129+ if ($ sourceShare ->getSharedBy () && $ sourceShare ->getSharedBy () !== $ sharedBy && $ sourceShare ->getShareOwner () !== $ sourceShare ->getSharedBy ()) {
1130+ $ sharer = $ sourceShare ->getSharedBy ();
1131+ try {
1132+ $ sharerNode = $ this ->rootFolder ->getUserFolder ($ sharer )->getFirstNodeById ($ fileId );
1133+ } catch (NotFoundException ) {
1134+ return ;
1135+ }
1136+ if ($ sharerNode === null ) {
1137+ return ;
11441138 }
1139+ $ this ->reshareNotificationForSharer (
1140+ $ sharer ,
1141+ $ subject ,
1142+ $ shareWith ,
1143+ $ fileId ,
1144+ $ this ->getUserRelativePath ($ sharer , $ sharerNode ->getPath ()),
1145+ $ fileSource instanceof File,
1146+ );
11451147 }
11461148 }
11471149
0 commit comments