Merge pull request #12952 from MrPetovan/bug/fatal-errors
Address a few fatal errors
This commit is contained in:
commit
c77266de98
|
@ -109,6 +109,8 @@ interface IHandleUserSessions extends IHandleSessions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the session variable that contains the contact IDs for the visitor's contact URL
|
* Set the session variable that contains the contact IDs for the visitor's contact URL
|
||||||
|
*
|
||||||
|
* @param string $my_url
|
||||||
*/
|
*/
|
||||||
public function setVisitorsContacts();
|
public function setVisitorsContacts(string $my_url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,9 +140,9 @@ class UserSession implements IHandleUserSessions
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public function setVisitorsContacts()
|
public function setVisitorsContacts(string $my_url)
|
||||||
{
|
{
|
||||||
$this->session->set('remote', Contact::getVisitorByUrl($this->session->get('my_url')));
|
$this->session->set('remote', Contact::getVisitorByUrl($my_url));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Factory\Api\Mastodon;
|
namespace Friendica\Factory\Api\Mastodon;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Object\Api\Mastodon\Relationship as RelationshipEntity;
|
use Friendica\Object\Api\Mastodon\Relationship as RelationshipEntity;
|
||||||
use Friendica\BaseFactory;
|
use Friendica\BaseFactory;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -41,9 +42,15 @@ class Relationship extends BaseFactory
|
||||||
$pcid = !empty($cdata['public']) ? $cdata['public'] : $contactId;
|
$pcid = !empty($cdata['public']) ? $cdata['public'] : $contactId;
|
||||||
$cid = !empty($cdata['user']) ? $cdata['user'] : $contactId;
|
$cid = !empty($cdata['user']) ? $cdata['user'] : $contactId;
|
||||||
|
|
||||||
|
$contact = Contact::getById($cid);
|
||||||
|
if (!$contact) {
|
||||||
|
$this->logger->warning('Target contact not found', ['contactId' => $contactId, 'uid' => $uid, 'pcid' => $pcid, 'cid' => $cid]);
|
||||||
|
throw new HTTPException\NotFoundException('Contact not found.');
|
||||||
|
}
|
||||||
|
|
||||||
return new RelationshipEntity(
|
return new RelationshipEntity(
|
||||||
$pcid,
|
$pcid,
|
||||||
Contact::getById($cid),
|
$contact,
|
||||||
Contact\User::isBlocked($cid, $uid),
|
Contact\User::isBlocked($cid, $uid),
|
||||||
Contact\User::isIgnored($cid, $uid)
|
Contact\User::isIgnored($cid, $uid)
|
||||||
);
|
);
|
||||||
|
|
|
@ -795,14 +795,16 @@ class Profile
|
||||||
$visitor = Contact::getById($cid);
|
$visitor = Contact::getById($cid);
|
||||||
|
|
||||||
// Authenticate the visitor.
|
// Authenticate the visitor.
|
||||||
$_SESSION['authenticated'] = 1;
|
DI::userSession()->setMultiple([
|
||||||
$_SESSION['visitor_id'] = $visitor['id'];
|
'authenticated' => 1,
|
||||||
$_SESSION['visitor_handle'] = $visitor['addr'];
|
'visitor_id' => $visitor['id'],
|
||||||
$_SESSION['visitor_home'] = $visitor['url'];
|
'visitor_handle' => $visitor['addr'],
|
||||||
$_SESSION['my_url'] = $visitor['url'];
|
'visitor_home' => $visitor['url'],
|
||||||
$_SESSION['remote_comment'] = $visitor['subscribe'];
|
'my_url' => $visitor['url'],
|
||||||
|
'remote_comment' => $visitor['subscribe'],
|
||||||
|
]);
|
||||||
|
|
||||||
DI::userSession()->setVisitorsContacts();
|
DI::userSession()->setVisitorsContacts($visitor['url']);
|
||||||
|
|
||||||
$a->setContactId($visitor['id']);
|
$a->setContactId($visitor['id']);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use GuzzleHttp\Psr7\Uri;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Follow extends BaseModule
|
class Follow extends BaseModule
|
||||||
|
@ -223,6 +224,12 @@ class Follow extends BaseModule
|
||||||
|
|
||||||
protected function followRemoteItem(string $url)
|
protected function followRemoteItem(string $url)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
$uri = new Uri($url);
|
||||||
|
if (!$uri->getScheme()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
|
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
|
||||||
if (!$itemId) {
|
if (!$itemId) {
|
||||||
// If the user-specific search failed, we search and probe a public post
|
// If the user-specific search failed, we search and probe a public post
|
||||||
|
@ -235,5 +242,8 @@ class Follow extends BaseModule
|
||||||
$this->baseUrl->redirect('display/' . $item['guid']);
|
$this->baseUrl->redirect('display/' . $item['guid']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,11 +121,14 @@ class Contacts extends Module\BaseProfile
|
||||||
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
|
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
|
||||||
['order' => ['uid' => 'DESC']]
|
['order' => ['uid' => 'DESC']]
|
||||||
);
|
);
|
||||||
return Module\Contact::getContactTemplateVars($contact);
|
return $contact ? Module\Contact::getContactTemplateVars($contact) : null;
|
||||||
},
|
},
|
||||||
Model\Contact::selectToArray(['uri-id'], $condition, $params)
|
Model\Contact::selectToArray(['uri-id'], $condition, $params)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Remove nonexistent contacts
|
||||||
|
$contacts = array_filter($contacts);
|
||||||
|
|
||||||
$desc = '';
|
$desc = '';
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'followers':
|
case 'followers':
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Relationship extends BaseDataTransferObject
|
||||||
* @param bool $blocked "true" if user is blocked
|
* @param bool $blocked "true" if user is blocked
|
||||||
* @param bool $muted "true" if user is muted
|
* @param bool $muted "true" if user is muted
|
||||||
*/
|
*/
|
||||||
public function __construct(int $contactId, array $contactRecord = [], bool $blocked = false, bool $muted = false)
|
public function __construct(int $contactId, array $contactRecord, bool $blocked = false, bool $muted = false)
|
||||||
{
|
{
|
||||||
$this->id = (string)$contactId;
|
$this->id = (string)$contactId;
|
||||||
$this->following = false;
|
$this->following = false;
|
||||||
|
|
|
@ -323,19 +323,21 @@ class Authentication
|
||||||
*/
|
*/
|
||||||
public function setForUser(App $a, array $user_record, bool $login_initial = false, bool $interactive = false, bool $login_refresh = false)
|
public function setForUser(App $a, array $user_record, bool $login_initial = false, bool $interactive = false, bool $login_refresh = false)
|
||||||
{
|
{
|
||||||
|
$my_url = $this->baseUrl . '/profile/' . $user_record['nickname'];
|
||||||
|
|
||||||
$this->session->setMultiple([
|
$this->session->setMultiple([
|
||||||
'uid' => $user_record['uid'],
|
'uid' => $user_record['uid'],
|
||||||
'theme' => $user_record['theme'],
|
'theme' => $user_record['theme'],
|
||||||
'mobile-theme' => $this->pConfig->get($user_record['uid'], 'system', 'mobile_theme'),
|
'mobile-theme' => $this->pConfig->get($user_record['uid'], 'system', 'mobile_theme'),
|
||||||
'authenticated' => 1,
|
'authenticated' => 1,
|
||||||
'page_flags' => $user_record['page-flags'],
|
'page_flags' => $user_record['page-flags'],
|
||||||
'my_url' => $this->baseUrl . '/profile/' . $user_record['nickname'],
|
'my_url' => $my_url,
|
||||||
'my_address' => $user_record['nickname'] . '@' . substr($this->baseUrl, strpos($this->baseUrl, '://') + 3),
|
'my_address' => $user_record['nickname'] . '@' . substr($this->baseUrl, strpos($this->baseUrl, '://') + 3),
|
||||||
'addr' => $this->remoteAddress,
|
'addr' => $this->remoteAddress,
|
||||||
'nickname' => $user_record['nickname'],
|
'nickname' => $user_record['nickname'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->session->setVisitorsContacts();
|
$this->session->setVisitorsContacts($my_url);
|
||||||
|
|
||||||
$member_since = strtotime($user_record['register_date']);
|
$member_since = strtotime($user_record['register_date']);
|
||||||
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
|
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user