@@ -1745,66 +1745,36 @@ private function parseDate(string $expireDate): \DateTime {
17451745	 * @throws ShareNotFound 
17461746	 */ 
17471747	private  function  getShareById (string  $ idIShare 
1748- 		$ sharenull ;
1749- 
1750- 		// First check if it is an internal share. 
1751- 		try  {
1752- 			$ share$ this shareManager ->getShareById ('ocinternal: '  . $ id$ this userId );
1753- 			return  $ share
1754- 		} catch  (ShareNotFound $ e
1755- 			// Do nothing, just try the other share type 
1756- 		}
1757- 
1758- 
1759- 		try  {
1760- 			if  ($ this shareManager ->shareProviderExists (IShare::TYPE_CIRCLE )) {
1761- 				$ share$ this shareManager ->getShareById ('ocCircleShare: '  . $ id$ this userId );
1762- 				return  $ share
1763- 			}
1764- 		} catch  (ShareNotFound $ e
1765- 			// Do nothing, just try the other share type 
1766- 		}
1767- 
1768- 		try  {
1769- 			if  ($ this shareManager ->shareProviderExists (IShare::TYPE_EMAIL )) {
1770- 				$ share$ this shareManager ->getShareById ('ocMailShare: '  . $ id$ this userId );
1771- 				return  $ share
1772- 			}
1773- 		} catch  (ShareNotFound $ e
1774- 			// Do nothing, just try the other share type 
1775- 		}
1776- 
1777- 		try  {
1778- 			$ share$ this shareManager ->getShareById ('ocRoomShare: '  . $ id$ this userId );
1779- 			return  $ share
1780- 		} catch  (ShareNotFound $ e
1781- 			// Do nothing, just try the other share type 
1782- 		}
1748+ 		$ providers
1749+ 			'ocinternal '  => null , // No type check needed 
1750+ 			'ocCircleShare '  => IShare::TYPE_CIRCLE ,
1751+ 			'ocMailShare '  => IShare::TYPE_EMAIL ,
1752+ 			'ocRoomShare '  => null ,
1753+ 			'deck '  => IShare::TYPE_DECK ,
1754+ 			'sciencemesh '  => IShare::TYPE_SCIENCEMESH ,
1755+ 		];
17831756
1784- 		try  {
1785- 			if  ($ this shareManager ->shareProviderExists (IShare::TYPE_DECK )) {
1786- 				$ share$ this shareManager ->getShareById ('deck: '  . $ id$ this userId );
1787- 				return  $ share
1788- 			}
1789- 		} catch  (ShareNotFound $ e
1790- 			// Do nothing, just try the other share type 
1757+ 		// Add federated sharing as a provider only if it's allowed 
1758+ 		if  ($ this shareManager ->outgoingServer2ServerSharesAllowed ()) {
1759+ 			$ providers'ocFederatedSharing ' ] = null ; // No type check needed 
17911760		}
17921761
1793- 		try  {
1794- 			if  ($ this shareManager ->shareProviderExists (IShare::TYPE_SCIENCEMESH )) {
1795- 				$ share$ this shareManager ->getShareById ('sciencemesh: '  . $ id$ this userId );
1796- 				return  $ share
1762+ 		foreach  ($ providersas  $ prefix$ type
1763+ 			try  {
1764+ 				if  ($ typenull  || $ this shareManager ->shareProviderExists ($ type
1765+ 					return  $ this shareManager ->getShareById ($ prefix': '  . $ id$ this userId );
1766+ 				}
1767+ 			} catch  (ShareNotFound $ e
1768+ 				// Do nothing, continue to next provider 
1769+ 			} catch  (\Exception   $ e
1770+ 				$ this logger ->warning ('Unexpected error in share provider ' , [
1771+ 					'shareId '  => $ id
1772+ 					'provider '  => $ prefix
1773+ 					'exception '  => $ e
1774+ 				]);
17971775			}
1798- 		} catch  (ShareNotFound $ e
1799- 			// Do nothing, just try the other share type 
18001776		}
1801- 
1802- 		if  (!$ this shareManager ->outgoingServer2ServerSharesAllowed ()) {
1803- 			throw  new  ShareNotFound ();
1804- 		}
1805- 		$ share$ this shareManager ->getShareById ('ocFederatedSharing: '  . $ id$ this userId );
1806- 
1807- 		return  $ share
1777+ 		throw  new  ShareNotFound ();
18081778	}
18091779
18101780	/** 
0 commit comments