<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
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;
}
protected function post(array $request = [])
{
- parent::post($request);
-
if (!$this->session->getLocalUserId()) {
throw new ForbiddenException($this->t('Access denied.'));
}
- if (!empty($request['url'])) {
- $this->baseUrl->redirect($request['url']);
+ if (isset($request['cancel']) || empty($request['url'])) {
+ $this->baseUrl->redirect('contact');
}
- $url = Probe::cleanURI($this->session->get('url'));
+ $url = Probe::cleanURI($request['url']);
+
+ $this->process($url);
}
protected function content(array $request = []): string
}
$uid = $this->session->getLocalUserId();
- $url = Probe::cleanURI(trim($request['url'] ?? ''));
+
+ // uri is used by the /authorize_interaction Mastodon route
+ $url = Probe::cleanURI(trim($request['uri'] ?? $request['url'] ?? ''));
// Issue 6874: Allow remote following from Peertube
if (strpos($url, 'acct:') === 0) {
// Don't try to add a pending contact
$userContact = Contact::selectFirst(['pending'], [
- "`uid` = ? AND ((`rel` != ?) OR (`network` = ?)) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
+ "`uid` = ? AND ((`rel` != ?) OR (`network` = ?)) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
$uid, Contact::FOLLOWER, Protocol::DFRN,
Strings::normaliseLink($url),
- Strings::normaliseLink($url), $url,
- Protocol::STATUSNET]);
+ Strings::normaliseLink($url), $url]);
if (!empty($userContact['pending'])) {
$this->sysMessages->addNotice($this->t('You already added this contact.'));
$this->process($contact['url']);
}
- $request = $this->baseUrl . '/follow';
- $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
+ $requestUrl = $this->baseUrl . '/contact/follow';
+ $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
$owner = User::getOwnerDataById($uid);
if (empty($owner)) {
'$submit' => $submit,
'$cancel' => $this->t('Cancel'),
- '$request' => $request,
+ '$action' => $requestUrl,
'$name' => $contact['name'],
'$url' => $contact['url'],
'$zrl' => Profile::zrl($contact['url']),
'$addnote_field' => ['dfrn-request-message', $this->t('Add a personal note:')],
]);
- $this['aside'] = '';
+ $this->page['aside'] = '';
if (!in_array($protocol, [Protocol::PHANTOM, Protocol::MAIL])) {
- $this['aside'] = VCard::getHTML($contact);
+ $this->page['aside'] = VCard::getHTML($contact);
$output .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'),
- ['$title' => $this->t('Status Messages and Posts')]
+ ['$title' => $this->t('Posts and Replies')]
);
// Show last public posts
protected function process(string $url)
{
- $returnPath = 'follow?rul=' . 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