From 87291e30a45e660b47a9ea95326200c88cc642dd Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 31 Oct 2022 19:10:30 +0100 Subject: [PATCH] Found some more follow-links --- src/Content/Item.php | 2 +- src/Content/Widget/VCard.php | 2 +- src/Model/Contact.php | 2 +- src/Module/Contact/Follow.php | 9 +++------ static/routes.config.php | 2 +- view/theme/vier/theme.php | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Content/Item.php b/src/Content/Item.php index 3d6443fe3f..c867582b94 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -401,7 +401,7 @@ class Item if ((($cid == 0) || ($rel == Contact::FOLLOWER)) && in_array($item['network'], Protocol::FEDERATED)) { - $menu[$this->l10n->t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']) . '&auto=1'; + $menu[$this->l10n->t('Connect/Follow')] = 'contact/follow?url=' . urlencode($item['author-link']) . '&auto=1'; } } else { $menu = [$this->l10n->t('View Profile') => $item['author-link']]; diff --git a/src/Content/Widget/VCard.php b/src/Content/Widget/VCard.php index 1edbf63c8c..adb77319c0 100644 --- a/src/Content/Widget/VCard.php +++ b/src/Content/Widget/VCard.php @@ -85,7 +85,7 @@ class VCard if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) { $unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1'; } elseif (!$pending) { - $follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1'; + $follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1'; } } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 0ae7003f05..7c83e03511 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1178,7 +1178,7 @@ class Contact if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) { $unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1'; } elseif(!$contact['pending']) { - $follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1'; + $follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1'; } } diff --git a/src/Module/Contact/Follow.php b/src/Module/Contact/Follow.php index fe523f491e..0e1e129e92 100644 --- a/src/Module/Contact/Follow.php +++ b/src/Module/Contact/Follow.php @@ -48,20 +48,17 @@ class Follow extends BaseModule protected $session; /** @var SystemMessages */ protected $sysMessages; - /** @var App */ - protected $app; /** @var IManageConfigValues */ protected $config; /** @var App\Page */ protected $page; - public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, SystemMessages $sysMessages, App $app, IManageConfigValues $config, App\Page $page, array $server, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, SystemMessages $sysMessages, IManageConfigValues $config, App\Page $page, array $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->session = $session; $this->sysMessages = $sysMessages; - $this->app = $app; $this->config = $config; $this->page = $page; } @@ -202,9 +199,9 @@ class Follow extends BaseModule protected function process(string $url) { - $returnPath = 'follow?url=' . urlencode($url); + $returnPath = 'contact/follow?url=' . urlencode($url); - $result = Contact::createFromProbeForUser($this->app->getLoggedInUserId(), $url); + $result = Contact::createFromProbeForUser($this->session->getLocalUserId(), $url); if (!$result['success']) { // Possibly it is a remote item and not an account diff --git a/static/routes.config.php b/static/routes.config.php index d21e9efae5..2b7f5b98da 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -387,7 +387,7 @@ return [ '/hidden' => [Module\Contact::class, [R::GET]], '/ignored' => [Module\Contact::class, [R::GET]], '/hovercard' => [Module\Contact\Hovercard::class, [R::GET]], - '/follow[/{url}]' => [Module\Contact\Follow::class, [R::GET, R::POST]], + '/follow[/{url}]' => [Module\Contact\Follow::class, [R::GET, R::POST]], '/unfollow' => [Module\Contact\Unfollow::class, [R::GET, R::POST]], ], diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 2d313cb29e..bb647bc638 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -154,7 +154,7 @@ function vier_community_info() foreach ($contacts as $contact) { $entry = Renderer::replaceMacros($tpl, [ '$id' => $contact['id'], - '$profile_link' => 'follow/?url='.urlencode($contact['url']), + '$profile_link' => 'contact/follow/?url='.urlencode($contact['url']), '$photo' => Contact::getMicro($contact), '$alt_text' => $contact['name'], ]);