2626use OCA \Osm \AppInfo \Application ;
2727use OCA \Osm \Service \OsmAPIService ;
2828use OCA \Osm \Service \UtilsService ;
29+ use OCP \Collaboration \Reference \IPublicReferenceProvider ;
2930use OCP \Collaboration \Reference \IReference ;
3031use OCP \Collaboration \Reference \IReferenceManager ;
3132use OCP \Collaboration \Reference \IReferenceProvider ;
3637
3738use OCP \IURLGenerator ;
3839
39- class OsmLocationReferenceProvider implements IReferenceProvider {
40+ class OsmLocationReferenceProvider implements IReferenceProvider, IPublicReferenceProvider {
4041
4142 private const RICH_OBJECT_TYPE = Application::APP_ID . '_location ' ;
4243
@@ -57,22 +58,28 @@ public function __construct(
5758 */
5859 public function matchReference (string $ referenceText ): bool {
5960 $ adminLinkPreviewEnabled = $ this ->appConfig ->getValueString (Application::APP_ID , 'link_preview_enabled ' , '1 ' ) === '1 ' ;
60- $ userLinkPreviewEnabled = $ this ->userConfig ->getValueString ($ this ->userId , Application::APP_ID , 'link_preview_enabled ' , '1 ' ) === '1 ' ;
61+ $ userLinkPreviewEnabled = $ this ->userId === null
62+ ? true
63+ : $ this ->userConfig ->getValueString ($ this ->userId , Application::APP_ID , 'link_preview_enabled ' , '1 ' ) === '1 ' ;
6164 if (!$ adminLinkPreviewEnabled || !$ userLinkPreviewEnabled ) {
6265 return false ;
6366 }
6467
6568 return $ this ->getCoordinates ($ referenceText ) !== null || $ this ->getLocationTypeId ($ referenceText ) !== null ;
6669 }
6770
71+ public function resolveReferencePublic (string $ referenceText , string $ sharingToken ): ?IReference {
72+ return $ this ->resolveReference ($ referenceText );
73+ }
74+
6875 /**
6976 * @inheritDoc
7077 */
7178 public function resolveReference (string $ referenceText ): ?IReference {
7279 if ($ this ->matchReference ($ referenceText )) {
7380 $ coords = $ this ->getCoordinates ($ referenceText );
7481 $ locationTypeId = $ this ->getLocationTypeId ($ referenceText );
75- $ locationInfo = $ this ->osmAPIService ->getLocationInfo ($ this -> userId , $ locationTypeId ['id ' ], $ locationTypeId ['type ' ]);
82+ $ locationInfo = $ this ->osmAPIService ->getLocationInfo ($ locationTypeId ['id ' ], $ locationTypeId ['type ' ]);
7683 if ($ locationInfo !== null ) {
7784 $ locationInfo ['url ' ] = $ referenceText ;
7885 $ reference = new Reference ($ referenceText );
@@ -185,6 +192,13 @@ public function getCacheKey(string $referenceId): ?string {
185192 return $ referenceId ;
186193 }
187194
195+ /**
196+ * @inheritDoc
197+ */
198+ public function getCacheKeyPublic (string $ referenceId , string $ sharingToken ): ?string {
199+ return null ;
200+ }
201+
188202 /**
189203 * @param string $userId
190204 * @return void
0 commit comments