@@ -22,12 +22,10 @@ class WayfProvider {
2222 // The default wayf page route.
2323 public const WAYF_ROUTE = '/wayf ' ;
2424 public const DISCOVERY_ROUTE = '/discover ' ;
25- public const INVITE_ACCEPT_DIALOG = '/index.php/apps/contacts ' . FederatedInvitesService::OCM_INVITE_ACCEPT_DIALOG_ROUTE ;
2625
2726 public function __construct (
2827 private IAppConfig $ appConfig ,
2928 private IClientService $ httpClient ,
30- private FederatedInvitesService $ federatedInvitesService ,
3129 private LoggerInterface $ logger ,
3230 private IOCMDiscoveryService $ discovery ,
3331 private IURLGenerator $ urlGenerator ,
@@ -73,7 +71,8 @@ public function getMeshProviders(): array {
7371 }
7472 if ($ inviteAcceptDialog === '' ) {
7573 // We fall back on Nextcloud default path
76- $ inviteAcceptDialog = $ prov ['url ' ] . WayfProvider::INVITE_ACCEPT_DIALOG ;
74+ $ inviteAcceptDialogPath = self ::getInviteAcceptDialogPath ();
75+ $ inviteAcceptDialog = rtrim ($ prov ['url ' ], '/ ' ) . $ inviteAcceptDialogPath ;
7776 }
7877 $ federations [$ fed ][] = [
7978 'provider ' => $ disc ->getProvider (),
@@ -116,27 +115,17 @@ public function getMeshProvidersFromCache(): array {
116115 * @return string|null the WAYF login page endpoint or null if it could not be created
117116 */
118117 public function getWayfEndpoint (): string |null {
119- $ appRootUrl = $ this ->getAppRootUrl ();
120- if (empty ($ appRootUrl )) {
121- $ this ->logger ->error ("Unable to create WAYF endpoint " , ['app ' => Application::APP_ID ]);
122- return null ;
123- }
124- $ appRootUrl = trim ($ appRootUrl , '/ ' );
125- $ wayfEndpoint = 'https:// ' . $ this ->federatedInvitesService ->getProviderFQDN () . "/ $ appRootUrl/ " . Application::APP_ID . WayfProvider::WAYF_ROUTE ;
126- return $ this ->appConfig ->getValueString (Application::APP_ID , 'wayf_endpoint ' , $ wayfEndpoint );
118+ // default wayf endpoint
119+ $ defaultWayfEndpoint = $ this ->urlGenerator ->linkToRouteAbsolute (Application::APP_ID . '.federated_invites.wayf ' );
120+ return $ this ->appConfig ->getValueString (Application::APP_ID , 'wayf_endpoint ' , $ defaultWayfEndpoint );
127121 }
128122
129123 /**
130- * Returns this app root url. Currently either '/apps' or '/custom_apps'.
131- * @return string|null the app root url or null if the app root url could not be determined
124+ * Returns the path of the invite accept dialog route.
125+ *
126+ * @return string
132127 */
133- private function getAppRootUrl (): string |null {
134- foreach (\OC ::$ APPSROOTS as $ appRoot ) {
135- if (str_starts_with (__DIR__ , $ appRoot ['path ' ])) {
136- return $ appRoot ['url ' ];
137- }
138- }
139- $ this ->logger ->error ("Could not determine app root url " , ['app ' => Application::APP_ID ]);
140- return null ;
128+ public function getInviteAcceptDialogPath (): string {
129+ return $ this ->urlGenerator ->linkToRoute (Application::APP_ID . '.federated_invites.invite_accept_dialog ' );
141130 }
142131}
0 commit comments