Extend IHandleUserSessions from IHandleSessions and adapt classes

This commit is contained in:
Philipp 2022-10-23 20:41:17 +02:00
parent b72d727a06
commit b5bc1b0844
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
14 changed files with 165 additions and 138 deletions

View file

@ -29,7 +29,6 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database;
use Friendica\Model\Contact;
@ -54,24 +53,21 @@ class Introduction extends BaseFactory
private $l10n;
/** @var IManagePersonalConfigValues */
private $pConfig;
/** @var IHandleSessions */
private $session;
/** @var IHandleUserSessions */
private $userSession;
private $session;
/** @var string */
private $nick;
public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleSessions $session, IHandleUserSessions $userSession)
public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session)
{
parent::__construct($logger);
$this->dba = $dba;
$this->baseUrl = $baseUrl;
$this->l10n = $l10n;
$this->pConfig = $pConfig;
$this->session = $session;
$this->userSession = $userSession;
$this->nick = $app->getLoggedInUserNickname() ?? '';
$this->dba = $dba;
$this->baseUrl = $baseUrl;
$this->l10n = $l10n;
$this->pConfig = $pConfig;
$this->session = $session;
$this->nick = $app->getLoggedInUserNickname() ?? '';
}
/**
@ -111,7 +107,7 @@ class Introduction extends BaseFactory
LEFT JOIN `contact` AS `sugggest-contact` ON `intro`.`suggest-cid` = `sugggest-contact`.`id`
WHERE `intro`.`uid` = ? $sql_extra
LIMIT ?, ?",
$_SESSION['uid'],
$this->session->getLocalUserId(),
$start,
$limit
);
@ -146,7 +142,7 @@ class Introduction extends BaseFactory
'url' => $intro['furl'],
'zrl' => Contact::magicLink($intro['furl']),
'hidden' => $intro['hidden'] == 1,
'post_newfriend' => (intval($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'post_newfriend' => (intval($this->pConfig->get($this->session->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'note' => $intro['note'],
'request' => $intro['frequest'] . '?addr=' . $return_addr]);
@ -162,7 +158,7 @@ class Introduction extends BaseFactory
'label' => (($intro['network'] !== Protocol::OSTATUS) ? 'friend_request' : 'follower'),
'str_type' => (($intro['network'] !== Protocol::OSTATUS) ? $this->l10n->t('Friend/Connect Request') : $this->l10n->t('New Follower')),
'dfrn_id' => $intro['issued-id'],
'uid' => $this->session->get('uid'),
'uid' => $this->session->getLocalUserId(),
'intro_id' => $intro['intro_id'],
'contact_id' => $intro['contact-id'],
'photo' => Contact::getPhoto($intro),
@ -171,7 +167,7 @@ class Introduction extends BaseFactory
'about' => BBCode::convert($intro['about'], false),
'keywords' => $intro['keywords'],
'hidden' => $intro['hidden'] == 1,
'post_newfriend' => (intval($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'post_newfriend' => (intval($this->pConfig->get($this->session->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'url' => $intro['url'],
'zrl' => Contact::magicLink($intro['url']),
'addr' => $intro['addr'],
@ -182,7 +178,7 @@ class Introduction extends BaseFactory
}
}
} catch (Exception $e) {
$this->logger->warning('Select failed.', ['uid' => $_SESSION['uid'], 'exception' => $e]);
$this->logger->warning('Select failed.', ['uid' => $this->session->getLocalUserId(), 'exception' => $e]);
}
return $formattedIntroductions;