mirror of
https://github.com/friendica/friendica
synced 2024-12-22 13:20:15 +00:00
Replace all calls for App::getContactId() with AppHelper
This commit is contained in:
parent
cad3311afb
commit
d9087b4f7c
4 changed files with 46 additions and 39 deletions
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\Content\Conversation;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
|
@ -17,7 +17,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseProfile;
|
||||
|
||||
function notes_init(App $a)
|
||||
function notes_init(AppHelper $appHelper)
|
||||
{
|
||||
if (! DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
|
@ -27,7 +27,7 @@ function notes_init(App $a)
|
|||
}
|
||||
|
||||
|
||||
function notes_content(App $a, bool $update = false)
|
||||
function notes_content(AppHelper $appHelper, bool $update = false)
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
|
@ -46,11 +46,11 @@ function notes_content(App $a, bool $update = false)
|
|||
'acl_data' => '',
|
||||
];
|
||||
|
||||
$o .= DI::conversation()->statusEditor($x, $a->getContactId());
|
||||
$o .= DI::conversation()->statusEditor($x, $appHelper->getContactId());
|
||||
}
|
||||
|
||||
$condition = ['uid' => DI::userSession()->getLocalUserId(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT,
|
||||
'contact-id'=> $a->getContactId()];
|
||||
'contact-id'=> $appHelper->getContactId()];
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\App\Arguments;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -27,16 +29,16 @@ class Redir extends \Friendica\BaseModule
|
|||
private $session;
|
||||
/** @var Database */
|
||||
private $database;
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var AppHelper */
|
||||
private $appHelper;
|
||||
|
||||
public function __construct(App $app, Database $database, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
public function __construct(AppHelper $appHelper, Database $database, IHandleUserSessions $session, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->session = $session;
|
||||
$this->database = $database;
|
||||
$this->app = $app;
|
||||
$this->appHelper = $appHelper;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -100,14 +102,14 @@ class Redir extends \Friendica\BaseModule
|
|||
// We don't use magic auth when there is no visitor, we are on the same system, or we visit our own stuff
|
||||
if (empty($visitor) || Strings::compareLink($basepath, $this->baseUrl) || Strings::compareLink($contact_url, $visitor)) {
|
||||
$this->logger->info('Redirecting without magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
|
||||
$this->app->redirect($target_url);
|
||||
$this->appHelper->redirect($target_url);
|
||||
}
|
||||
|
||||
$separator = strpos($target_url, '?') ? '&' : '?';
|
||||
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
|
||||
|
||||
$this->logger->info('Redirecting with magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
|
||||
$this->app->redirect($target_url);
|
||||
$this->appHelper->redirect($target_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,9 +137,9 @@ class Redir extends \Friendica\BaseModule
|
|||
$this->checkUrl($contact_url, $url);
|
||||
$target_url = $url ?: $contact_url;
|
||||
|
||||
if (!empty($this->app->getContactId()) && $this->app->getContactId() == $cid) {
|
||||
if (!empty($this->appHelper->getContactId()) && $this->appHelper->getContactId() == $cid) {
|
||||
// Local user is already authenticated.
|
||||
$this->app->redirect($target_url);
|
||||
$this->appHelper->redirect($target_url);
|
||||
}
|
||||
|
||||
if ($contact['uid'] == 0 && $this->session->getLocalUserId()) {
|
||||
|
@ -148,10 +150,10 @@ class Redir extends \Friendica\BaseModule
|
|||
$cid = $contact['id'];
|
||||
}
|
||||
|
||||
if (!empty($this->app->getContactId()) && $this->app->getContactId() == $cid) {
|
||||
if (!empty($this->appHelper->getContactId()) && $this->appHelper->getContactId() == $cid) {
|
||||
// Local user is already authenticated.
|
||||
$this->logger->info('Contact already authenticated. Redirecting to target url', ['url' => $contact['url'], 'name' => $contact['name'], 'target_url' => $target_url]);
|
||||
$this->app->redirect($target_url);
|
||||
$this->appHelper->redirect($target_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +168,7 @@ class Redir extends \Friendica\BaseModule
|
|||
if (($host == $remotehost) && ($this->session->getRemoteContactID($this->session->get('visitor_visiting')) == $this->session->get('visitor_id'))) {
|
||||
// Remote user is already authenticated.
|
||||
$this->logger->info('Contact already authenticated. Redirecting to target url', ['url' => $contact['url'], 'name' => $contact['name'], 'target_url' => $target_url]);
|
||||
$this->app->redirect($target_url);
|
||||
$this->appHelper->redirect($target_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ class Redir extends \Friendica\BaseModule
|
|||
}
|
||||
|
||||
$this->logger->info('redirecting to ' . $target_url);
|
||||
$this->app->redirect($target_url);
|
||||
$this->appHelper->redirect($target_url);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use DateTime;
|
||||
use Friendica\App;
|
||||
use Friendica\App\Arguments;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\App\Page;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\ACL;
|
||||
|
@ -41,7 +44,7 @@ class Compose extends BaseModule
|
|||
/** @var ACLFormatter */
|
||||
private $ACLFormatter;
|
||||
|
||||
/** @var App\Page */
|
||||
/** @var Page */
|
||||
private $page;
|
||||
|
||||
/** @var IManagePersonalConfigValues */
|
||||
|
@ -53,11 +56,11 @@ class Compose extends BaseModule
|
|||
/** @var UserSession */
|
||||
private $session;
|
||||
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var AppHelper */
|
||||
private $appHelper;
|
||||
|
||||
|
||||
public function __construct(App $app, UserSession $session, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
public function __construct(AppHelper $appHelper, UserSession $session, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
|
@ -67,7 +70,7 @@ class Compose extends BaseModule
|
|||
$this->pConfig = $pConfig;
|
||||
$this->config = $config;
|
||||
$this->session = $session;
|
||||
$this->app = $app;
|
||||
$this->appHelper = $appHelper;
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -87,7 +90,7 @@ class Compose extends BaseModule
|
|||
return Login::form('compose');
|
||||
}
|
||||
|
||||
if ($this->app->getCurrentTheme() !== 'frio') {
|
||||
if ($this->appHelper->getCurrentTheme() !== 'frio') {
|
||||
throw new NotImplementedException($this->l10n->t('This feature is only available with the frio theme.'));
|
||||
}
|
||||
|
||||
|
@ -115,7 +118,7 @@ class Compose extends BaseModule
|
|||
$compose_title = $this->l10n->t('Compose new personal note');
|
||||
$type = 'note';
|
||||
$doesFederate = false;
|
||||
$contact_allow_list = [$this->app->getContactId()];
|
||||
$contact_allow_list = [$this->appHelper->getContactId()];
|
||||
$circle_allow_list = [];
|
||||
$contact_deny_list = [];
|
||||
$circle_deny_list = [];
|
||||
|
@ -158,12 +161,12 @@ class Compose extends BaseModule
|
|||
$this->page->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
|
||||
$this->page->registerFooterScript(Theme::getPathForFile('js/compose.js'));
|
||||
|
||||
$contact = Contact::getById($this->app->getContactId());
|
||||
$contact = Contact::getById($this->appHelper->getContactId());
|
||||
|
||||
if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'set_creation_date')) {
|
||||
$created_at = Temporal::getDateTimeField(
|
||||
new \DateTime(DBA::NULL_DATETIME),
|
||||
new \DateTime('now'),
|
||||
new DateTime(DBA::NULL_DATETIME),
|
||||
new DateTime('now'),
|
||||
null,
|
||||
$this->l10n->t('Created at'),
|
||||
'created_at'
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Exception;
|
||||
use Friendica\App;
|
||||
use Friendica\App\Arguments;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
|
@ -35,8 +37,8 @@ use Psr\Log\LoggerInterface;
|
|||
*/
|
||||
class Magic extends BaseModule
|
||||
{
|
||||
/** @var App */
|
||||
protected $app;
|
||||
/** @var AppHelper */
|
||||
protected $appHelper;
|
||||
/** @var Database */
|
||||
protected $dba;
|
||||
/** @var ICanSendHttpRequests */
|
||||
|
@ -44,11 +46,11 @@ class Magic extends BaseModule
|
|||
/** @var IHandleUserSessions */
|
||||
protected $userSession;
|
||||
|
||||
public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, IHandleUserSessions $userSession, $server, array $parameters = [])
|
||||
public function __construct(AppHelper $appHelper, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, IHandleUserSessions $userSession, $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->app = $app;
|
||||
$this->appHelper = $appHelper;
|
||||
$this->dba = $dba;
|
||||
$this->httpClient = $httpClient;
|
||||
$this->userSession = $userSession;
|
||||
|
@ -85,11 +87,11 @@ class Magic extends BaseModule
|
|||
if (empty($contact)) {
|
||||
if (!$owa) {
|
||||
$this->logger->info('No contact record found, no oWA, redirecting to destination.', ['request' => $request, 'server' => $_SERVER, 'dest' => $dest]);
|
||||
$this->app->redirect($dest);
|
||||
$this->appHelper->redirect($dest);
|
||||
}
|
||||
} else {
|
||||
// Redirect if the contact is already authenticated on this site.
|
||||
if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl)) !== false) {
|
||||
if ($this->appHelper->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl)) !== false) {
|
||||
$this->logger->info('Contact is already authenticated, redirecting to destination.', ['dest' => $dest]);
|
||||
System::externalRedirect($dest);
|
||||
}
|
||||
|
@ -99,12 +101,12 @@ class Magic extends BaseModule
|
|||
|
||||
if (!$this->userSession->getLocalUserId() || !$owa) {
|
||||
$this->logger->notice('Not logged in or not OWA, redirecting to destination.', ['uid' => $this->userSession->getLocalUserId(), 'owa' => $owa, 'dest' => $dest]);
|
||||
$this->app->redirect($dest);
|
||||
$this->appHelper->redirect($dest);
|
||||
}
|
||||
|
||||
$dest = Network::removeUrlParameter($dest, 'zid');
|
||||
$dest = Network::removeUrlParameter($dest, 'f');
|
||||
|
||||
|
||||
// OpenWebAuth
|
||||
$owner = User::getOwnerDataById($this->userSession->getLocalUserId());
|
||||
|
||||
|
@ -169,7 +171,7 @@ class Magic extends BaseModule
|
|||
$j = json_decode($curlResult->getBodyString(), true);
|
||||
if (empty($j) || !$j['success']) {
|
||||
$this->logger->notice('Invalid JSON, redirecting to destination.', ['json' => $j, 'dest' => $dest]);
|
||||
$this->app->redirect($dest);
|
||||
$this->appHelper->redirect($dest);
|
||||
}
|
||||
|
||||
if ($j['encrypted_token']) {
|
||||
|
|
Loading…
Reference in a new issue