mirror of
https://github.com/friendica/friendica
synced 2024-12-23 16:40:17 +00:00
Merge pull request #12077 from nupplaphil/feat/move_follow
Move mod/follow.php to src/Module
This commit is contained in:
commit
df69dc0edb
12 changed files with 333 additions and 304 deletions
210
mod/follow.php
210
mod/follow.php
|
@ -1,210 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (C) 2010-2022, the Friendica project
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Widget;
|
|
||||||
use Friendica\Core\Protocol;
|
|
||||||
use Friendica\Core\Renderer;
|
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Model\Profile;
|
|
||||||
use Friendica\Model\Item;
|
|
||||||
use Friendica\Network\Probe;
|
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\Model\Post;
|
|
||||||
use Friendica\Model\User;
|
|
||||||
use Friendica\Util\Strings;
|
|
||||||
|
|
||||||
function follow_post(App $a)
|
|
||||||
{
|
|
||||||
if (!DI::userSession()->getLocalUserId()) {
|
|
||||||
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_REQUEST['cancel'])) {
|
|
||||||
DI::baseUrl()->redirect('contact');
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = Probe::cleanURI($_REQUEST['url']);
|
|
||||||
|
|
||||||
follow_process($a, $url);
|
|
||||||
}
|
|
||||||
|
|
||||||
function follow_content(App $a)
|
|
||||||
{
|
|
||||||
$return_path = 'contact';
|
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId()) {
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
|
||||||
DI::baseUrl()->redirect($return_path);
|
|
||||||
// NOTREACHED
|
|
||||||
}
|
|
||||||
|
|
||||||
$uid = DI::userSession()->getLocalUserId();
|
|
||||||
|
|
||||||
$url = Probe::cleanURI(trim($_REQUEST['url'] ?? ''));
|
|
||||||
|
|
||||||
// Issue 6874: Allow remote following from Peertube
|
|
||||||
if (strpos($url, 'acct:') === 0) {
|
|
||||||
$url = str_replace('acct:', '', $url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$url) {
|
|
||||||
DI::baseUrl()->redirect($return_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$submit = DI::l10n()->t('Submit Request');
|
|
||||||
|
|
||||||
// Don't try to add a pending contact
|
|
||||||
$user_contact = DBA::selectFirst('contact', ['pending'], ["`uid` = ? AND ((`rel` != ?) OR (`network` = ?)) AND
|
|
||||||
(`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
|
|
||||||
$uid, Contact::FOLLOWER, Protocol::DFRN, Strings::normaliseLink($url),
|
|
||||||
Strings::normaliseLink($url), $url, Protocol::STATUSNET]);
|
|
||||||
|
|
||||||
if (DBA::isResult($user_contact)) {
|
|
||||||
if ($user_contact['pending']) {
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('You already added this contact.'));
|
|
||||||
$submit = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$contact = Contact::getByURL($url, true);
|
|
||||||
|
|
||||||
// Possibly it is a mail contact
|
|
||||||
if (empty($contact)) {
|
|
||||||
$contact = Probe::uri($url, Protocol::MAIL, $uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($contact) || ($contact['network'] == Protocol::PHANTOM)) {
|
|
||||||
// Possibly it is a remote item and not an account
|
|
||||||
follow_remote_item($url);
|
|
||||||
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t("The network type couldn't be detected. Contact can't be added."));
|
|
||||||
$submit = '';
|
|
||||||
$contact = ['url' => $url, 'network' => Protocol::PHANTOM, 'name' => $url, 'keywords' => ''];
|
|
||||||
}
|
|
||||||
|
|
||||||
$protocol = Contact::getProtocol($contact['url'], $contact['network']);
|
|
||||||
|
|
||||||
if (($protocol == Protocol::DIASPORA) && !DI::config()->get('system', 'diaspora_enabled')) {
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added."));
|
|
||||||
$submit = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($protocol == Protocol::OSTATUS) && DI::config()->get('system', 'ostatus_disabled')) {
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t("OStatus support is disabled. Contact can't be added."));
|
|
||||||
$submit = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($protocol == Protocol::MAIL) {
|
|
||||||
$contact['url'] = $contact['addr'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($_REQUEST['auto'])) {
|
|
||||||
follow_process($a, $contact['url']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$request = DI::baseUrl() . '/follow';
|
|
||||||
$tpl = Renderer::getMarkupTemplate('auto_request.tpl');
|
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
|
||||||
if (empty($owner)) {
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
|
||||||
DI::baseUrl()->redirect($return_path);
|
|
||||||
// NOTREACHED
|
|
||||||
}
|
|
||||||
|
|
||||||
$myaddr = $owner['url'];
|
|
||||||
|
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
|
||||||
'$header' => DI::l10n()->t('Connect/Follow'),
|
|
||||||
'$pls_answer' => DI::l10n()->t('Please answer the following:'),
|
|
||||||
'$your_address' => DI::l10n()->t('Your Identity Address:'),
|
|
||||||
'$url_label' => DI::l10n()->t('Profile URL'),
|
|
||||||
'$keywords_label'=> DI::l10n()->t('Tags:'),
|
|
||||||
'$submit' => $submit,
|
|
||||||
'$cancel' => DI::l10n()->t('Cancel'),
|
|
||||||
|
|
||||||
'$action' => $request,
|
|
||||||
'$name' => $contact['name'],
|
|
||||||
'$url' => $contact['url'],
|
|
||||||
'$zrl' => Profile::zrl($contact['url']),
|
|
||||||
'$myaddr' => $myaddr,
|
|
||||||
'$keywords' => $contact['keywords'],
|
|
||||||
|
|
||||||
'$does_know_you' => ['knowyou', DI::l10n()->t('%s knows you', $contact['name'])],
|
|
||||||
'$addnote_field' => ['dfrn-request-message', DI::l10n()->t('Add a personal note:')],
|
|
||||||
]);
|
|
||||||
|
|
||||||
DI::page()['aside'] = '';
|
|
||||||
|
|
||||||
if (!in_array($protocol, [Protocol::PHANTOM, Protocol::MAIL])) {
|
|
||||||
DI::page()['aside'] = Widget\VCard::getHTML($contact);
|
|
||||||
|
|
||||||
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'),
|
|
||||||
['$title' => DI::l10n()->t('Status Messages and Posts')]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Show last public posts
|
|
||||||
$o .= Contact::getPostsFromUrl($contact['url']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
function follow_process(App $a, string $url)
|
|
||||||
{
|
|
||||||
$return_path = 'follow?url=' . urlencode($url);
|
|
||||||
|
|
||||||
$result = Contact::createFromProbeForUser($a->getLoggedInUserId(), $url);
|
|
||||||
|
|
||||||
if ($result['success'] == false) {
|
|
||||||
// Possibly it is a remote item and not an account
|
|
||||||
follow_remote_item($url);
|
|
||||||
|
|
||||||
if ($result['message']) {
|
|
||||||
DI::sysmsg()->addNotice($result['message']);
|
|
||||||
}
|
|
||||||
DI::baseUrl()->redirect($return_path);
|
|
||||||
} elseif ($result['cid']) {
|
|
||||||
DI::baseUrl()->redirect('contact/' . $result['cid']);
|
|
||||||
}
|
|
||||||
|
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('The contact could not be added.'));
|
|
||||||
|
|
||||||
DI::baseUrl()->redirect($return_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
function follow_remote_item($url)
|
|
||||||
{
|
|
||||||
$item_id = Item::fetchByLink($url, DI::userSession()->getLocalUserId());
|
|
||||||
if (!$item_id) {
|
|
||||||
// If the user-specific search failed, we search and probe a public post
|
|
||||||
$item_id = Item::fetchByLink($url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($item_id)) {
|
|
||||||
$item = Post::selectFirst(['guid'], ['id' => $item_id]);
|
|
||||||
if (DBA::isResult($item)) {
|
|
||||||
DI::baseUrl()->redirect('display/' . $item['guid']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -401,7 +401,7 @@ class Item
|
||||||
|
|
||||||
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
|
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
|
||||||
in_array($item['network'], Protocol::FEDERATED)) {
|
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 {
|
} else {
|
||||||
$menu = [$this->l10n->t('View Profile') => $item['author-link']];
|
$menu = [$this->l10n->t('View Profile') => $item['author-link']];
|
||||||
|
|
|
@ -85,7 +85,7 @@ class VCard
|
||||||
if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
|
if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
|
||||||
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
|
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||||
} elseif (!$pending) {
|
} elseif (!$pending) {
|
||||||
$follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1';
|
$follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class APContact
|
||||||
'addr' => $local_owner['addr'],
|
'addr' => $local_owner['addr'],
|
||||||
'baseurl' => $local_owner['baseurl'],
|
'baseurl' => $local_owner['baseurl'],
|
||||||
'url' => $local_owner['url'],
|
'url' => $local_owner['url'],
|
||||||
'subscribe' => $local_owner['baseurl'] . '/follow?url={uri}'];
|
'subscribe' => $local_owner['baseurl'] . '/contact/follow?url={uri}'];
|
||||||
|
|
||||||
if (!empty($local_owner['alias']) && ($local_owner['url'] != $local_owner['alias'])) {
|
if (!empty($local_owner['alias']) && ($local_owner['url'] != $local_owner['alias'])) {
|
||||||
$data['alias'] = $local_owner['alias'];
|
$data['alias'] = $local_owner['alias'];
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ class Contact
|
||||||
if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
|
if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
|
||||||
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
|
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||||
} elseif(!$contact['pending']) {
|
} elseif(!$contact['pending']) {
|
||||||
$follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1';
|
$follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ class Profile
|
||||||
if ($visitor_is_following) {
|
if ($visitor_is_following) {
|
||||||
$unfollow_link = $visitor_base_path . '/contact/unfollow?url=' . urlencode($profile_url) . '&auto=1';
|
$unfollow_link = $visitor_base_path . '/contact/unfollow?url=' . urlencode($profile_url) . '&auto=1';
|
||||||
} else {
|
} else {
|
||||||
$follow_link = $visitor_base_path . '/follow?url=' . urlencode($profile_url) . '&auto=1';
|
$follow_link = $visitor_base_path . '/contact/follow?url=' . urlencode($profile_url) . '&auto=1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
238
src/Module/Contact/Follow.php
Normal file
238
src/Module/Contact/Follow.php
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Module\Contact;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Content\Widget\VCard;
|
||||||
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
|
use Friendica\Model\Profile;
|
||||||
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Module\Response;
|
||||||
|
use Friendica\Navigation\SystemMessages;
|
||||||
|
use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
|
use Friendica\Network\Probe;
|
||||||
|
use Friendica\Util\Profiler;
|
||||||
|
use Friendica\Util\Strings;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class Follow extends BaseModule
|
||||||
|
{
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
protected $session;
|
||||||
|
/** @var SystemMessages */
|
||||||
|
protected $sysMessages;
|
||||||
|
/** @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, 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->config = $config;
|
||||||
|
$this->page = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function post(array $request = [])
|
||||||
|
{
|
||||||
|
if (!$this->session->getLocalUserId()) {
|
||||||
|
throw new ForbiddenException($this->t('Access denied.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($request['cancel']) || empty($request['url'])) {
|
||||||
|
$this->baseUrl->redirect('contact');
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = Probe::cleanURI($request['url']);
|
||||||
|
|
||||||
|
$this->process($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function content(array $request = []): string
|
||||||
|
{
|
||||||
|
$returnPath = 'contact';
|
||||||
|
|
||||||
|
if (!$this->session->getLocalUserId()) {
|
||||||
|
$this->sysMessages->addNotice($this->t('Permission denied.'));
|
||||||
|
$this->baseUrl->redirect($returnPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uid = $this->session->getLocalUserId();
|
||||||
|
$url = Probe::cleanURI(trim($request['url'] ?? ''));
|
||||||
|
|
||||||
|
// Issue 6874: Allow remote following from Peertube
|
||||||
|
if (strpos($url, 'acct:') === 0) {
|
||||||
|
$url = str_replace('acct:', '', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
$this->baseUrl->redirect($returnPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$submit = $this->t('Submit Request');
|
||||||
|
|
||||||
|
// 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, Contact::FOLLOWER, Protocol::DFRN,
|
||||||
|
Strings::normaliseLink($url),
|
||||||
|
Strings::normaliseLink($url), $url,
|
||||||
|
Protocol::STATUSNET]);
|
||||||
|
|
||||||
|
if (!empty($userContact['pending'])) {
|
||||||
|
$this->sysMessages->addNotice($this->t('You already added this contact.'));
|
||||||
|
$submit = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact = Contact::getByURL($url, true);
|
||||||
|
|
||||||
|
// Possibly it is a mail contact
|
||||||
|
if (empty($contact)) {
|
||||||
|
$contact = Probe::uri($url, Protocol::MAIL, $uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($contact) || ($contact['network'] == Protocol::PHANTOM)) {
|
||||||
|
// Possibly it is a remote item and not an account
|
||||||
|
$this->followRemoteItem($url);
|
||||||
|
|
||||||
|
$this->sysMessages->addNotice($this->t('The network type couldn\'t be detected. Contact can\'t be added.'));
|
||||||
|
$submit = '';
|
||||||
|
$contact = ['url' => $url, 'network' => Protocol::PHANTOM, 'name' => $url, 'keywords' => ''];
|
||||||
|
}
|
||||||
|
|
||||||
|
$protocol = Contact::getProtocol($contact['url'], $contact['network']);
|
||||||
|
|
||||||
|
if (($protocol == Protocol::DIASPORA) && !$this->config->get('system', 'diaspora_enabled')) {
|
||||||
|
$this->sysMessages->addNotice($this->t('Diaspora support isn\'t enabled. Contact can\'t be added.'));
|
||||||
|
$submit = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($protocol == Protocol::OSTATUS) && $this->config->get('system', 'ostatus_disabled')) {
|
||||||
|
$this->sysMessages->addNotice($this->t("OStatus support is disabled. Contact can't be added."));
|
||||||
|
$submit = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($protocol == Protocol::MAIL) {
|
||||||
|
$contact['url'] = $contact['addr'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($request['auto'])) {
|
||||||
|
$this->process($contact['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$requestUrl = $this->baseUrl . '/contact/follow';
|
||||||
|
$tpl = Renderer::getMarkupTemplate('auto_request.tpl');
|
||||||
|
|
||||||
|
$owner = User::getOwnerDataById($uid);
|
||||||
|
if (empty($owner)) {
|
||||||
|
$this->sysMessages->addNotice($this->t('Permission denied.'));
|
||||||
|
$this->baseUrl->redirect($returnPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$myaddr = $owner['url'];
|
||||||
|
|
||||||
|
$output = Renderer::replaceMacros($tpl, [
|
||||||
|
'$header' => $this->t('Connect/Follow'),
|
||||||
|
'$pls_answer' => $this->t('Please answer the following:'),
|
||||||
|
'$your_address' => $this->t('Your Identity Address:'),
|
||||||
|
'$url_label' => $this->t('Profile URL'),
|
||||||
|
'$keywords_label' => $this->t('Tags:'),
|
||||||
|
'$submit' => $submit,
|
||||||
|
'$cancel' => $this->t('Cancel'),
|
||||||
|
|
||||||
|
'$action' => $requestUrl,
|
||||||
|
'$name' => $contact['name'],
|
||||||
|
'$url' => $contact['url'],
|
||||||
|
'$zrl' => Profile::zrl($contact['url']),
|
||||||
|
'$myaddr' => $myaddr,
|
||||||
|
'$keywords' => $contact['keywords'],
|
||||||
|
|
||||||
|
'$does_know_you' => ['knowyou', $this->t('%s knows you', $contact['name'])],
|
||||||
|
'$addnote_field' => ['dfrn-request-message', $this->t('Add a personal note:')],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->page['aside'] = '';
|
||||||
|
|
||||||
|
if (!in_array($protocol, [Protocol::PHANTOM, Protocol::MAIL])) {
|
||||||
|
$this->page['aside'] = VCard::getHTML($contact);
|
||||||
|
|
||||||
|
$output .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'),
|
||||||
|
['$title' => $this->t('Status Messages and Posts')]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Show last public posts
|
||||||
|
$output .= Contact::getPostsFromUrl($contact['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function process(string $url)
|
||||||
|
{
|
||||||
|
$returnPath = 'contact/follow?url=' . urlencode($url);
|
||||||
|
|
||||||
|
$result = Contact::createFromProbeForUser($this->session->getLocalUserId(), $url);
|
||||||
|
|
||||||
|
if (!$result['success']) {
|
||||||
|
// Possibly it is a remote item and not an account
|
||||||
|
$this->followRemoteItem($url);
|
||||||
|
|
||||||
|
if (!empty($result['message'])) {
|
||||||
|
$this->sysMessages->addNotice($result['message']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->baseUrl->redirect($returnPath);
|
||||||
|
} elseif (!empty($result['cid'])) {
|
||||||
|
$this->baseUrl->redirect('contact/' . $result['cid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sysMessages->addNotice($this->t('The contact could not be added.'));
|
||||||
|
$this->baseUrl->redirect($returnPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function followRemoteItem(string $url)
|
||||||
|
{
|
||||||
|
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
|
||||||
|
if (!$itemId) {
|
||||||
|
// If the user-specific search failed, we search and probe a public post
|
||||||
|
$itemId = Item::fetchByLink($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($itemId)) {
|
||||||
|
$item = Post::selectFirst(['guid'], ['id' => $itemId]);
|
||||||
|
if (!empty($item['guid'])) {
|
||||||
|
$this->baseUrl->redirect('display/' . $item['guid']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -122,7 +122,7 @@ class Xrd extends BaseModule
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
'template' => $baseURL . '/follow?url={uri}',
|
'template' => $baseURL . '/contact/follow?url={uri}',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => ActivityNamespace::FEED,
|
'rel' => ActivityNamespace::FEED,
|
||||||
|
@ -212,7 +212,7 @@ class Xrd extends BaseModule
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
'template' => $baseURL . '/follow?url={uri}',
|
'template' => $baseURL . '/contact/follow?url={uri}',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => 'magic-public-key',
|
'rel' => 'magic-public-key',
|
||||||
|
@ -312,7 +312,7 @@ class Xrd extends BaseModule
|
||||||
'11:link' => [
|
'11:link' => [
|
||||||
'@attributes' => [
|
'@attributes' => [
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
'template' => $baseURL . '/follow?url={uri}'
|
'template' => $baseURL . '/contact/follow?url={uri}'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'12:link' => [
|
'12:link' => [
|
||||||
|
|
|
@ -2185,7 +2185,7 @@ class Probe
|
||||||
'xmpp' => $owner['xmpp'], 'matrix' => $owner['matrix'],
|
'xmpp' => $owner['xmpp'], 'matrix' => $owner['matrix'],
|
||||||
'hide' => !$owner['net-publish'], 'batch' => '', 'notify' => $owner['notify'],
|
'hide' => !$owner['net-publish'], 'batch' => '', 'notify' => $owner['notify'],
|
||||||
'poll' => $owner['poll'], 'request' => $owner['request'], 'confirm' => $owner['confirm'],
|
'poll' => $owner['poll'], 'request' => $owner['request'], 'confirm' => $owner['confirm'],
|
||||||
'subscribe' => $approfile['generator']['url'] . '/follow?url={uri}', 'poco' => $owner['poco'],
|
'subscribe' => $approfile['generator']['url'] . '/contact/follow?url={uri}', 'poco' => $owner['poco'],
|
||||||
'following' => $approfile['following'], 'followers' => $approfile['followers'],
|
'following' => $approfile['following'], 'followers' => $approfile['followers'],
|
||||||
'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'],
|
'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'],
|
||||||
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
|
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
|
||||||
|
|
|
@ -387,6 +387,7 @@ return [
|
||||||
'/hidden' => [Module\Contact::class, [R::GET]],
|
'/hidden' => [Module\Contact::class, [R::GET]],
|
||||||
'/ignored' => [Module\Contact::class, [R::GET]],
|
'/ignored' => [Module\Contact::class, [R::GET]],
|
||||||
'/hovercard' => [Module\Contact\Hovercard::class, [R::GET]],
|
'/hovercard' => [Module\Contact\Hovercard::class, [R::GET]],
|
||||||
|
'/follow' => [Module\Contact\Follow::class, [R::GET, R::POST]],
|
||||||
'/unfollow' => [Module\Contact\Unfollow::class, [R::GET, R::POST]],
|
'/unfollow' => [Module\Contact\Unfollow::class, [R::GET, R::POST]],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 2022.12-dev\n"
|
"Project-Id-Version: 2022.12-dev\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2022-10-31 15:34-0400\n"
|
"POT-Creation-Date: 2022-10-31 19:59+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -18,8 +18,8 @@ msgstr ""
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
|
||||||
#: mod/cal.php:45 mod/cal.php:49 mod/follow.php:39 mod/redir.php:35
|
#: mod/cal.php:45 mod/cal.php:49 mod/redir.php:35 mod/redir.php:176
|
||||||
#: mod/redir.php:176 src/Module/Conversation/Community.php:193
|
#: src/Module/Contact/Follow.php:69 src/Module/Conversation/Community.php:193
|
||||||
#: src/Module/Debug/ItemBody.php:38 src/Module/Diaspora/Receive.php:57
|
#: src/Module/Debug/ItemBody.php:38 src/Module/Diaspora/Receive.php:57
|
||||||
#: src/Module/Item/Follow.php:41 src/Module/Item/Ignore.php:41
|
#: src/Module/Item/Follow.php:41 src/Module/Item/Ignore.php:41
|
||||||
#: src/Module/Item/Pin.php:41 src/Module/Item/Pin.php:56
|
#: src/Module/Item/Pin.php:41 src/Module/Item/Pin.php:56
|
||||||
|
@ -119,19 +119,19 @@ msgstr ""
|
||||||
msgid "The feed for this item is unavailable."
|
msgid "The feed for this item is unavailable."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: mod/editpost.php:38 mod/events.php:218 mod/follow.php:56 mod/follow.php:130
|
#: mod/editpost.php:38 mod/events.php:218 mod/item.php:181 mod/item.php:186
|
||||||
#: mod/item.php:181 mod/item.php:186 mod/item.php:870 mod/message.php:69
|
#: mod/item.php:870 mod/message.php:69 mod/message.php:114 mod/notes.php:44
|
||||||
#: mod/message.php:114 mod/notes.php:44 mod/ostatus_subscribe.php:33
|
#: mod/ostatus_subscribe.php:33 mod/photos.php:159 mod/photos.php:886
|
||||||
#: mod/photos.php:159 mod/photos.php:886 mod/repair_ostatus.php:31
|
#: mod/repair_ostatus.php:31 mod/settings.php:40 mod/settings.php:50
|
||||||
#: mod/settings.php:40 mod/settings.php:50 mod/settings.php:156
|
#: mod/settings.php:156 mod/suggest.php:34 mod/uimport.php:33
|
||||||
#: mod/suggest.php:34 mod/uimport.php:33 src/Module/Attach.php:56
|
#: src/Module/Attach.php:56 src/Module/BaseApi.php:94
|
||||||
#: src/Module/BaseApi.php:94 src/Module/BaseNotifications.php:98
|
#: src/Module/BaseNotifications.php:98 src/Module/Contact/Advanced.php:60
|
||||||
#: src/Module/Contact/Advanced.php:60 src/Module/Contact/Unfollow.php:66
|
#: src/Module/Contact/Follow.php:86 src/Module/Contact/Follow.php:158
|
||||||
#: src/Module/Contact/Unfollow.php:80 src/Module/Contact/Unfollow.php:112
|
#: src/Module/Contact/Unfollow.php:66 src/Module/Contact/Unfollow.php:80
|
||||||
#: src/Module/Delegation.php:118 src/Module/FollowConfirm.php:38
|
#: src/Module/Contact/Unfollow.php:112 src/Module/Delegation.php:118
|
||||||
#: src/Module/FriendSuggest.php:57 src/Module/Group.php:40
|
#: src/Module/FollowConfirm.php:38 src/Module/FriendSuggest.php:57
|
||||||
#: src/Module/Group.php:83 src/Module/Invite.php:42 src/Module/Invite.php:131
|
#: src/Module/Group.php:40 src/Module/Group.php:83 src/Module/Invite.php:42
|
||||||
#: src/Module/Notifications/Notification.php:76
|
#: src/Module/Invite.php:131 src/Module/Notifications/Notification.php:76
|
||||||
#: src/Module/Notifications/Notification.php:107
|
#: src/Module/Notifications/Notification.php:107
|
||||||
#: src/Module/Profile/Attachment/Upload.php:97 src/Module/Profile/Common.php:55
|
#: src/Module/Profile/Attachment/Upload.php:97 src/Module/Profile/Common.php:55
|
||||||
#: src/Module/Profile/Contacts.php:55 src/Module/Profile/Photos/Upload.php:108
|
#: src/Module/Profile/Contacts.php:55 src/Module/Profile/Photos/Upload.php:108
|
||||||
|
@ -269,8 +269,8 @@ msgid "Preview"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: mod/editpost.php:130 mod/fbrowser.php:119 mod/fbrowser.php:146
|
#: mod/editpost.php:130 mod/fbrowser.php:119 mod/fbrowser.php:146
|
||||||
#: mod/follow.php:144 mod/photos.php:999 mod/photos.php:1100 mod/tagrm.php:35
|
#: mod/photos.php:999 mod/photos.php:1100 mod/tagrm.php:35 mod/tagrm.php:127
|
||||||
#: mod/tagrm.php:127 src/Content/Conversation.php:389
|
#: src/Content/Conversation.php:389 src/Module/Contact/Follow.php:171
|
||||||
#: src/Module/Contact/Revoke.php:109 src/Module/Contact/Unfollow.php:126
|
#: src/Module/Contact/Revoke.php:109 src/Module/Contact/Unfollow.php:126
|
||||||
#: src/Module/Profile/RemoteFollow.php:134
|
#: src/Module/Profile/RemoteFollow.php:134
|
||||||
#: src/Module/Security/TwoFactor/SignOut.php:125
|
#: src/Module/Security/TwoFactor/SignOut.php:125
|
||||||
|
@ -452,72 +452,6 @@ msgstr ""
|
||||||
msgid "Files"
|
msgid "Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: mod/follow.php:74 src/Module/Contact/Unfollow.php:125
|
|
||||||
#: src/Module/Profile/RemoteFollow.php:133
|
|
||||||
msgid "Submit Request"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:84
|
|
||||||
msgid "You already added this contact."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:100
|
|
||||||
msgid "The network type couldn't be detected. Contact can't be added."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:108
|
|
||||||
msgid "Diaspora support isn't enabled. Contact can't be added."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:113
|
|
||||||
msgid "OStatus support is disabled. Contact can't be added."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:138 src/Content/Item.php:404 src/Content/Widget.php:80
|
|
||||||
#: src/Model/Contact.php:1194 src/Model/Contact.php:1205
|
|
||||||
#: view/theme/vier/theme.php:198
|
|
||||||
msgid "Connect/Follow"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:139 src/Module/Profile/RemoteFollow.php:132
|
|
||||||
msgid "Please answer the following:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:140 src/Module/Contact/Unfollow.php:123
|
|
||||||
msgid "Your Identity Address:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:141 src/Module/Admin/Blocklist/Contact.php:116
|
|
||||||
#: src/Module/Contact/Profile.php:366 src/Module/Contact/Unfollow.php:129
|
|
||||||
#: src/Module/Notifications/Introductions.php:129
|
|
||||||
#: src/Module/Notifications/Introductions.php:198
|
|
||||||
msgid "Profile URL"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:142 src/Module/Contact/Profile.php:378
|
|
||||||
#: src/Module/Notifications/Introductions.php:191
|
|
||||||
#: src/Module/Profile/Profile.php:206
|
|
||||||
msgid "Tags:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:153
|
|
||||||
#, php-format
|
|
||||||
msgid "%s knows you"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:154
|
|
||||||
msgid "Add a personal note:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:163 src/Module/BaseProfile.php:59 src/Module/Contact.php:447
|
|
||||||
#: src/Module/Contact/Unfollow.php:138
|
|
||||||
msgid "Status Messages and Posts"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/follow.php:191
|
|
||||||
msgid "The contact could not be added."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/item.php:131 mod/item.php:135
|
#: mod/item.php:131 mod/item.php:135
|
||||||
msgid "Unable to locate original post."
|
msgid "Unable to locate original post."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -2284,6 +2218,12 @@ msgstr ""
|
||||||
msgid "Languages"
|
msgid "Languages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Content/Item.php:404 src/Content/Widget.php:80
|
||||||
|
#: src/Model/Contact.php:1194 src/Model/Contact.php:1205
|
||||||
|
#: src/Module/Contact/Follow.php:165 view/theme/vier/theme.php:198
|
||||||
|
msgid "Connect/Follow"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/Content/Nav.php:90
|
#: src/Content/Nav.php:90
|
||||||
msgid "Nothing new here"
|
msgid "Nothing new here"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -4417,6 +4357,13 @@ msgid_plural "%s total blocked contacts"
|
||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: src/Module/Admin/Blocklist/Contact.php:116 src/Module/Contact/Follow.php:168
|
||||||
|
#: src/Module/Contact/Profile.php:366 src/Module/Contact/Unfollow.php:129
|
||||||
|
#: src/Module/Notifications/Introductions.php:129
|
||||||
|
#: src/Module/Notifications/Introductions.php:198
|
||||||
|
msgid "Profile URL"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/Admin/Blocklist/Contact.php:116
|
#: src/Module/Admin/Blocklist/Contact.php:116
|
||||||
msgid "URL of the remote contact to block."
|
msgid "URL of the remote contact to block."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -6662,6 +6609,11 @@ msgstr[1] ""
|
||||||
msgid "Profile Details"
|
msgid "Profile Details"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/BaseProfile.php:59 src/Module/Contact.php:447
|
||||||
|
#: src/Module/Contact/Follow.php:190 src/Module/Contact/Unfollow.php:138
|
||||||
|
msgid "Status Messages and Posts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/BaseProfile.php:109
|
#: src/Module/BaseProfile.php:109
|
||||||
msgid "Only You Can See This"
|
msgid "Only You Can See This"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -6924,6 +6876,54 @@ msgid_plural "Contacts (%s)"
|
||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:102 src/Module/Contact/Unfollow.php:125
|
||||||
|
#: src/Module/Profile/RemoteFollow.php:133
|
||||||
|
msgid "Submit Request"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:113
|
||||||
|
msgid "You already added this contact."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:128
|
||||||
|
msgid "The network type couldn't be detected. Contact can't be added."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:136
|
||||||
|
msgid "Diaspora support isn't enabled. Contact can't be added."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:141
|
||||||
|
msgid "OStatus support is disabled. Contact can't be added."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:166 src/Module/Profile/RemoteFollow.php:132
|
||||||
|
msgid "Please answer the following:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:167 src/Module/Contact/Unfollow.php:123
|
||||||
|
msgid "Your Identity Address:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:169 src/Module/Contact/Profile.php:378
|
||||||
|
#: src/Module/Notifications/Introductions.php:191
|
||||||
|
#: src/Module/Profile/Profile.php:206
|
||||||
|
msgid "Tags:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:180
|
||||||
|
#, php-format
|
||||||
|
msgid "%s knows you"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:181
|
||||||
|
msgid "Add a personal note:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Contact/Follow.php:219
|
||||||
|
msgid "The contact could not be added."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/Contact/Profile.php:128
|
#: src/Module/Contact/Profile.php:128
|
||||||
msgid "Failed to update contact record."
|
msgid "Failed to update contact record."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -154,7 +154,7 @@ function vier_community_info()
|
||||||
foreach ($contacts as $contact) {
|
foreach ($contacts as $contact) {
|
||||||
$entry = Renderer::replaceMacros($tpl, [
|
$entry = Renderer::replaceMacros($tpl, [
|
||||||
'$id' => $contact['id'],
|
'$id' => $contact['id'],
|
||||||
'$profile_link' => 'follow/?url='.urlencode($contact['url']),
|
'$profile_link' => 'contact/follow?url=' . urlencode($contact['url']),
|
||||||
'$photo' => Contact::getMicro($contact),
|
'$photo' => Contact::getMicro($contact),
|
||||||
'$alt_text' => $contact['name'],
|
'$alt_text' => $contact['name'],
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue