summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2023-06-20 09:15:17 -0100
committerGitHub <noreply@github.com>2023-06-20 09:15:17 -0100
commit7a21adad3c5beed4d827085509af50ab69be37f8 (patch)
tree2ed11551a9df8413ae1fd25d7bd877be75fb1ab2
parent6f51c1b29a0cbb577469340207bd3ac310f46bf0 (diff)
parentcbeefae898227c7528c143ae478fd168671c8f64 (diff)
Merge pull request #1749 from nextcloud/fix/noid/cross-webfingerv0.6.1
allow other apps to register webfinger
-rw-r--r--appinfo/info.xml2
-rw-r--r--lib/AppInfo/Application.php7
-rw-r--r--lib/Controller/ActivityPubController.php2
-rw-r--r--lib/Controller/ApiController.php2
-rw-r--r--lib/Controller/LocalController.php2
-rw-r--r--lib/Controller/NavigationController.php10
-rw-r--r--lib/Controller/OAuthController.php4
-rw-r--r--lib/Controller/OStatusController.php2
-rw-r--r--lib/Controller/QueueController.php2
-rw-r--r--lib/Controller/SocialPubController.php10
-rw-r--r--lib/Dashboard/SocialWidget.php4
-rw-r--r--lib/Notification/Notifier.php6
-rw-r--r--lib/Providers/ContactsMenuProvider.php2
-rw-r--r--lib/Service/ConfigService.php18
-rw-r--r--lib/Service/InstanceService.php2
-rw-r--r--lib/Service/MiscService.php2
-rw-r--r--lib/Service/SignatureService.php2
-rw-r--r--lib/WellKnown/WebfingerHandler.php43
18 files changed, 76 insertions, 46 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 7d1be1da..767ce03f 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -6,7 +6,7 @@
<summary>🎉 Nextcloud becomes part of the federated social networks!</summary>
<description><![CDATA[
- ** Disclaimer: this is an BETA version **
+ ** Disclaimer: this is a BETA version **
**🎉 Nextcloud becomes part of the federated social networks!**
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 0f3c0c6e..764212df 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -53,10 +53,13 @@ require_once __DIR__ . '/../../vendor/autoload.php';
* @package OCA\Social\AppInfo
*/
class Application extends App implements IBootstrap {
- public const APP_NAME = 'social';
+ public const APP_ID = 'social';
+ public const APP_NAME = 'Social';
+ public const APP_SUBJECT = 'http://nextcloud.com/';
+ public const APP_REL = 'https://apps.nextcloud.com/apps/social';
public function __construct(array $params = []) {
- parent::__construct(self::APP_NAME, $params);
+ parent::__construct(self::APP_ID, $params);
}
public function register(IRegistrationContext $context): void {
diff --git a/lib/Controller/ActivityPubController.php b/lib/Controller/ActivityPubController.php
index 64ba4112..501a2403 100644
--- a/lib/Controller/ActivityPubController.php
+++ b/lib/Controller/ActivityPubController.php
@@ -89,7 +89,7 @@ class ActivityPubController extends Controller {
ConfigService $configService,
LoggerInterface $logger
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->socialPubController = $socialPubController;
$this->fediverseService = $fediverseService;
diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php
index 900ef551..75e61cba 100644
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -113,7 +113,7 @@ class ApiController extends Controller {
PostService $postService,
ConfigService $configService
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->urlGenerator = $urlGenerator;
$this->userSession = $userSession;
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index 863c4684..6946cd70 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -91,7 +91,7 @@ class LocalController extends Controller {
BoostService $boostService, LikeService $likeService, DocumentService $documentService,
MiscService $miscService
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->userId = $userId;
$this->cacheActorService = $cacheActorService;
diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php
index 0684a61a..3f82ea57 100644
--- a/lib/Controller/NavigationController.php
+++ b/lib/Controller/NavigationController.php
@@ -90,7 +90,7 @@ class NavigationController extends Controller {
CheckService $checkService,
MiscService $miscService
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->userId = $userId;
$this->l10n = $l10n;
@@ -140,8 +140,8 @@ class NavigationController extends Controller {
if ($cloudAddress !== null) {
$this->configService->setCloudUrl($cloudAddress);
} else {
- $this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', $serverData);
- return new TemplateResponse(Application::APP_NAME, 'main');
+ $this->initialStateService->provideInitialState(Application::APP_ID, 'serverData', $serverData);
+ return new TemplateResponse(Application::APP_ID, 'main');
}
}
}
@@ -172,8 +172,8 @@ class NavigationController extends Controller {
$serverData['checks'] = $checks;
}
- $this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', $serverData);
- return new TemplateResponse(Application::APP_NAME, 'main');
+ $this->initialStateService->provideInitialState(Application::APP_ID, 'serverData', $serverData);
+ return new TemplateResponse(Application::APP_ID, 'main');
}
private function setupCloudAddress(): string {
diff --git a/lib/Controller/OAuthController.php b/lib/Controller/OAuthController.php
index 680d4f08..0b1f74db 100644
--- a/lib/Controller/OAuthController.php
+++ b/lib/Controller/OAuthController.php
@@ -71,7 +71,7 @@ class OAuthController extends Controller {
LoggerInterface $logger,
IInitialState $initialState
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->userSession = $userSession;
$this->urlGenerator = $urlGenerator;
@@ -187,7 +187,7 @@ class OAuthController extends Controller {
$client = $this->clientService->getFromClientId($client_id);
$this->initialState->provideInitialState('appName', $client->getAppName());
- return new TemplateResponse(Application::APP_NAME, 'oauth2', [
+ return new TemplateResponse(Application::APP_ID, 'oauth2', [
'request' =>
[
'clientId' => $client_id,
diff --git a/lib/Controller/OStatusController.php b/lib/Controller/OStatusController.php
index 195c6f72..72996f06 100644
--- a/lib/Controller/OStatusController.php
+++ b/lib/Controller/OStatusController.php
@@ -64,7 +64,7 @@ class OStatusController extends Controller {
IRequest $request, IInitialStateService $initialStateService, CacheActorService $cacheActorService, AccountService $accountService,
CurlService $curlService, MiscService $miscService, IUserSession $userSession
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->initialStateService = $initialStateService;
$this->cacheActorService = $cacheActorService;
diff --git a/lib/Controller/QueueController.php b/lib/Controller/QueueController.php
index 82731f58..16bf1b2a 100644
--- a/lib/Controller/QueueController.php
+++ b/lib/Controller/QueueController.php
@@ -56,7 +56,7 @@ class QueueController extends Controller {
IRequest $request, RequestQueueService $requestQueueService, ActivityService $activityService,
MiscService $miscService
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->requestQueueService = $requestQueueService;
$this->activityService = $activityService;
diff --git a/lib/Controller/SocialPubController.php b/lib/Controller/SocialPubController.php
index 07278909..1255e2f1 100644
--- a/lib/Controller/SocialPubController.php
+++ b/lib/Controller/SocialPubController.php
@@ -74,7 +74,7 @@ class SocialPubController extends Controller {
CacheActorService $cacheActorService, AccountService $accountService, StreamService $streamService,
ConfigService $configService
) {
- parent::__construct(Application::APP_NAME, $request);
+ parent::__construct(Application::APP_ID, $request);
$this->userId = $userId;
$this->initialStateService = $initialStateService;
@@ -113,7 +113,7 @@ class SocialPubController extends Controller {
$this->initialStateService->provideInitialState('social', 'serverData', [
'public' => true,
]);
- $page = new PublicTemplateResponse(Application::APP_NAME, 'main', $data);
+ $page = new PublicTemplateResponse(Application::APP_ID, 'main', $data);
$page->setStatus($status);
$page->setHeaderTitle($this->l10n->t('Social'));
@@ -190,10 +190,10 @@ class SocialPubController extends Controller {
'application' => 'Social'
];
- $this->initialStateService->provideInitialState(Application::APP_NAME, 'item', $stream);
- $this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', [
+ $this->initialStateService->provideInitialState(Application::APP_ID, 'item', $stream);
+ $this->initialStateService->provideInitialState(Application::APP_ID, 'serverData', [
'public' => ($this->userId === null),
]);
- return new TemplateResponse(Application::APP_NAME, 'main', $data);
+ return new TemplateResponse(Application::APP_ID, 'main', $data);
}
}
diff --git a/lib/Dashboard/SocialWidget.php b/lib/Dashboard/SocialWidget.php
index ad5395b9..1b6f1f2a 100644
--- a/lib/Dashboard/SocialWidget.php
+++ b/lib/Dashboard/SocialWidget.php
@@ -79,7 +79,7 @@ class SocialWidget implements IWidget {
* @inheritDoc
*/
public function load(): void {
- \OCP\Util::addScript(Application::APP_NAME, 'social-dashboard');
- \OCP\Util::addStyle(Application::APP_NAME, 'dashboard');
+ \OCP\Util::addScript(Application::APP_ID, 'social-dashboard');
+ \OCP\Util::addStyle(Application::APP_ID, 'dashboard');
}
}
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php
index fd1fc17c..b3096b98 100644
--- a/lib/Notification/Notifier.php
+++ b/lib/Notification/Notifier.php
@@ -76,7 +76,7 @@ class Notifier implements INotifier {
* @since 17.0.0
*/
public function getID(): string {
- return Application::APP_NAME;
+ return Application::APP_ID;
}
/**
@@ -97,11 +97,11 @@ class Notifier implements INotifier {
* @throws InvalidArgumentException
*/
public function prepare(INotification $notification, string $languageCode): INotification {
- if ($notification->getApp() !== Application::APP_NAME) {
+ if ($notification->getApp() !== Application::APP_ID) {
throw new InvalidArgumentException();
}
- $l10n = $this->factory->get(Application::APP_NAME, $languageCode);
+ $l10n = $this->factory->get(Application::APP_ID, $languageCode);
$notification->setIcon(
$this->url->getAbsoluteURL($this->url->imagePath('social', 'social_dark.svg'))
diff --git a/lib/Providers/ContactsMenuProvider.php b/lib/Providers/ContactsMenuProvider.php
index 15479e4c..ae818aa9 100644
--- a/lib/Providers/ContactsMenuProvider.php
+++ b/lib/Providers/ContactsMenuProvider.php
@@ -97,7 +97,7 @@ class ContactsMenuProvider implements IProvider {
'social.ActivityPub.actorAlias', ['username' => $actor->getPreferredUsername()]
);
- $action = $this->actionFactory->newLinkAction($icon, $action, $link, Application::APP_NAME);
+ $action = $this->actionFactory->newLinkAction($icon, $action, $link, Application::APP_ID);
$entry->addAction($action);
} catch (Exception $e) {
return;
diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php
index 033990b7..ae84aed5 100644
--- a/lib/Service/ConfigService.php
+++ b/lib/Service/ConfigService.php
@@ -132,7 +132,7 @@ class ConfigService {
$defaultValue = $this->defaults[$key];
}
- return $this->config->getAppValue(Application::APP_NAME, $key, $defaultValue);
+ return $this->config->getAppValue(Application::APP_ID, $key, $defaultValue);
}
/**
@@ -148,7 +148,7 @@ class ConfigService {
$defaultValue = $this->defaults[$key];
}
- return (int)$this->config->getAppValue(Application::APP_NAME, $key, $defaultValue);
+ return (int)$this->config->getAppValue(Application::APP_ID, $key, $defaultValue);
}
/**
@@ -160,7 +160,7 @@ class ConfigService {
* @return void
*/
public function setAppValue($key, $value) {
- $this->config->setAppValue(Application::APP_NAME, $key, $value);
+ $this->config->setAppValue(Application::APP_ID, $key, $value);
}
/**
@@ -171,7 +171,7 @@ class ConfigService {
* @return string
*/
public function deleteAppValue($key) {
- return $this->config->deleteAppValue(Application::APP_NAME, $key);
+ return $this->config->deleteAppValue(Application::APP_ID, $key);
}
/**
@@ -190,7 +190,7 @@ class ConfigService {
$defaultValue = '';
if ($app === '') {
- $app = Application::APP_NAME;
+ $app = Application::APP_ID;
if (array_key_exists($key, $this->defaults)) {
$defaultValue = $this->defaults[$key];
}
@@ -209,7 +209,7 @@ class ConfigService {
* @throws PreConditionNotMetException
*/
public function setUserValue($key, $value) {
- return $this->config->setUserValue($this->userId, Application::APP_NAME, $key, $value);
+ return $this->config->setUserValue($this->userId, Application::APP_ID, $key, $value);
}
/**
@@ -221,7 +221,7 @@ class ConfigService {
* @return string
*/
public function getValueForUser($userId, $key) {
- return $this->config->getUserValue($userId, Application::APP_NAME, $key);
+ return $this->config->getUserValue($userId, Application::APP_ID, $key);
}
/**
@@ -235,7 +235,7 @@ class ConfigService {
* @throws PreConditionNotMetException
*/
public function setValueForUser($userId, $key, $value) {
- return $this->config->setUserValue($userId, Application::APP_NAME, $key, $value);
+ return $this->config->setUserValue($userId, Application::APP_ID, $key, $value);
}
@@ -268,7 +268,7 @@ class ConfigService {
*
*/
public function unsetAppConfig() {
- $this->config->deleteAppValues(Application::APP_NAME);
+ $this->config->deleteAppValues(Application::APP_ID);
}
diff --git a/lib/Service/InstanceService.php b/lib/Service/InstanceService.php
index 4c756253..72daf3f9 100644
--- a/lib/Service/InstanceService.php
+++ b/lib/Service/InstanceService.php
@@ -62,7 +62,7 @@ class InstanceService {
public function createLocal(): Instance {
$instance = new Instance();
$instance->setLocal(true)
- ->setVersion($this->config->getAppValue(Application::APP_NAME, 'installed_version', '0.0'))
+ ->setVersion($this->config->getAppValue(Application::APP_ID, 'installed_version', '0.0'))
->setApprovalRequired(false)
->setDescription($this->config->getAppValue('theming', 'slogan', 'a safe home for your data'))
->setTitle($this->config->getAppValue('theming', 'name', 'Nextcloud Social'));
diff --git a/lib/Service/MiscService.php b/lib/Service/MiscService.php
index a7abbc7a..121db528 100644
--- a/lib/Service/MiscService.php
+++ b/lib/Service/MiscService.php
@@ -58,7 +58,7 @@ class MiscService {
*/
public function log(string $message, $level = 2) {
$data = array(
- 'app' => Application::APP_NAME,
+ 'app' => Application::APP_ID,
'level' => $level
);
diff --git a/lib/Service/SignatureService.php b/lib/Service/SignatureService.php
index dbe3261a..d95a9ffa 100644
--- a/lib/Service/SignatureService.php
+++ b/lib/Service/SignatureService.php
@@ -581,7 +581,7 @@ class SignatureService {
private static function getContextCacheFolder(): ISimpleFolder {
$path = 'context';
- $appData = Server::get(IAppDataFactory::class)->get(Application::APP_NAME);
+ $appData = Server::get(IAppDataFactory::class)->get(Application::APP_ID);
try {
$folder = $appData->getFolder($path);
} catch (NotFoundException $e) {
diff --git a/lib/WellKnown/WebfingerHandler.php b/lib/WellKnown/WebfingerHandler.php
index a6a11ed7..1ffd8889 100644
--- a/lib/WellKnown/WebfingerHandler.php
+++ b/lib/WellKnown/WebfingerHandler.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Social\WellKnown;
+use OCA\Social\AppInfo\Application;
use OCA\Social\Db\CacheActorsRequest;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
@@ -76,21 +77,29 @@ class WebfingerHandler implements IHandler {
try {
$this->fediverseService->jailed();
} catch (UnauthorizedFediverseException $e) {
- return null;
+ return $previousResponse;
}
+ $response = null;
switch (strtolower($service)) {
case 'webfinger':
- return $this->handleWebfinger($context);
+ $response = $this->handleWebfinger($context, $previousResponse);
+ break;
case 'nodeinfo':
- return $this->handleNodeInfo($context);
+ $response = $this->handleNodeInfo($context);
+ break;
case 'host-meta':
- return $this->handleHostMeta($context);
+ $response = $this->handleHostMeta($context);
+ break;
+ }
+
+ if ($response !== null) {
+ return $response;
}
- return null;
+ return $previousResponse;
}
@@ -101,16 +110,34 @@ class WebfingerHandler implements IHandler {
*
* @return IResponse|null
*/
- public function handleWebfinger(IRequestContext $context): ?IResponse {
+ public function handleWebfinger(IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
$subject = $context->getHttpRequest()->getParam('resource') ?? '';
- if (strpos($subject, 'acct:') === 0) {
+ if (str_starts_with($subject, 'acct:')) {
$subject = substr($subject, 5);
}
+ if ($subject === Application::APP_SUBJECT) {
+ if ($previousResponse !== null && method_exists($previousResponse, 'addLink')) {
+ $previousResponse->addLink(
+ Application::APP_REL,
+ 'application/json',
+ $this->urlGenerator->linkToRouteAbsolute('social.Navigation.navigate'),
+ [],
+ [
+ 'app' => Application::APP_ID,
+ 'name' => Application::APP_NAME,
+ 'version' => $this->configService->getAppValue('installed_version'),
+ ]
+ );
+ }
+
+ return $previousResponse;
+ }
+
$actor = null;
try {
$actor = $this->cacheActorService->getFromLocalAccount($subject);
- } catch (ActorDoesNotExistException | SocialAppConfigException $e) {
+ } catch (ActorDoesNotExistException|SocialAppConfigException $e) {
return null;
} catch (CacheActorDoesNotExistException $e) {
}