Merge remote-tracking branch 'upstream/develop' into diaspora-reshare

This commit is contained in:
Michael 2022-12-20 06:58:36 +00:00
commit 4db4d1843d
52 changed files with 5745 additions and 5298 deletions

View file

@ -64,7 +64,7 @@ class App
{
const PLATFORM = 'Friendica';
const CODENAME = 'Giant Rhubarb';
const VERSION = '2022.12-rc';
const VERSION = '2023.03-dev';
// Allow themes to control internal parameters
// by changing App values in theme.php

View file

@ -25,7 +25,7 @@ use Friendica\BaseEntity;
/**
* @property-read int $uid
* @property-read int $cid
* @property-read int $cid Either a public contact id (DFRN suggestion) or user-specific id (Contact::addRelationship)
* @property-read int|null $sid
* @property-read bool $knowyou
* @property-read string $note

View file

@ -736,22 +736,22 @@ class HTML
'[youtube]$2[/youtube]',
$s
);
$s = preg_replace(
'#<iframe[^>](.*?)https?://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)</iframe>#ism',
'[youtube]$2[/youtube]',
$s
);
$s = preg_replace(
'#<iframe[^>](.*?)https?://player.vimeo.com/video/([0-9]+)(.*?)</iframe>#ism',
'[vimeo]$2[/vimeo]',
$s
);
return $s;
}
/**
* transform link href and img src from relative to absolute
*
@ -764,30 +764,30 @@ class HTML
if (empty($base)) {
return $text;
}
$base = rtrim($base, '/');
$base2 = $base . "/";
// Replace links
$pattern = "/<a([^>]*) href=\"(?!http|https|\/)([^\"]*)\"/";
$replace = "<a\${1} href=\"" . $base2 . "\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<a([^>]*) href=\"(?!http|https)([^\"]*)\"/";
$replace = "<a\${1} href=\"" . $base . "\${2}\"";
$text = preg_replace($pattern, $replace, $text);
// Replace images
$pattern = "/<img([^>]*) src=\"(?!http|https|\/)([^\"]*)\"/";
$replace = "<img\${1} src=\"" . $base2 . "\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<img([^>]*) src=\"(?!http|https)([^\"]*)\"/";
$replace = "<img\${1} src=\"" . $base . "\${2}\"";
$text = preg_replace($pattern, $replace, $text);
// Done
return $text;
}
@ -907,19 +907,6 @@ class HTML
return Renderer::replaceMacros(Renderer::getMarkupTemplate('searchbox.tpl'), $values);
}
/**
* Replace naked text hyperlink with HTML formatted hyperlink
*
* @param string $s
* @return string
*/
public static function toLink(string $s): string
{
$s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $s);
$s = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism", '<$1$2=$3&$4>', $s);
return $s;
}
/**
* Given a HTML text and a set of filtering reasons, adds a content hiding header with the provided reasons
*

View file

@ -251,7 +251,7 @@ class System
// Don't show multiple calls from the Database classes to show the essential parts of the callstack
$func['database'] = in_array($func['class'], ['Friendica\Database\DBA', 'Friendica\Database\Database']);
if (!$previous['database'] || !$func['database']) {
if (!$previous['database'] || !$func['database']) {
$classparts = explode("\\", $func['class']);
$callstack[] = array_pop($classparts).'::'.$func['function'];
$previous = $func;
@ -678,7 +678,7 @@ class System
$html = BBCode::convert($rulelist, false, BBCode::EXTERNAL);
$msg = HTML::toPlaintext($html, 0, true);
foreach (explode("\n", $msg) as $line) {
foreach (explode("\n", trim($msg)) as $line) {
$line = trim($line);
if ($line) {
$rules[] = ['id' => (string)++$id, 'text' => $line];

View file

@ -74,12 +74,13 @@ class Photo extends BaseFactory
if (empty($photos)) {
throw new HTTPException\NotFoundException();
}
$data = $photos[0];
$data['id'] = $data['resource-id'];
$data = $photos[0];
$data['media-id'] = $data['id'];
$data['id'] = $data['resource-id'];
if (is_int($scale)) {
$data['data'] = base64_encode(ModelPhoto::getImageDataForPhoto($data));
} else {
unset($data['datasize']); //needed only with scale param
}
if ($type == 'xml') {
@ -99,12 +100,21 @@ class Photo extends BaseFactory
} else {
$data['link'][$id] = $link;
}
if (is_null($scale)) {
$data['scales'][] = [
'id' => $photo['id'],
'scale' => $photo['scale'],
'link' => $link,
'width' => $photo['width'],
'height' => $photo['height'],
'size' => $photo['datasize'],
];
}
}
unset($data['backend-class']);
unset($data['backend-ref']);
unset($data['resource-id']);
unset($data['scale']);
if ($with_posts) {
// retrieve item element for getting activities (like, dislike etc.) related to photo

View file

@ -24,6 +24,7 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\App\BaseURL;
use Friendica\BaseFactory;
use Friendica\Contact\Introduction\Entity\Introduction;
use Friendica\Database\DBA;
use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Network\HTTPException;
@ -49,18 +50,12 @@ class FollowRequest extends BaseFactory
*/
public function createFromIntroduction(Introduction $introduction): \Friendica\Object\Api\Mastodon\FollowRequest
{
$cdata = Contact::getPublicAndUserContactID($introduction->cid, $introduction->uid);
if (empty($cdata)) {
$account = DBA::selectFirst('account-user-view', [], ['id' => $introduction->cid, 'uid' => [0, $introduction->uid]]);
if (empty($account)) {
$this->logger->warning('Wrong introduction data', ['Introduction' => $introduction]);
throw new HTTPException\InternalServerErrorException('Wrong introduction data');
}
$publicContact = Contact::getById($cdata['public']);
$userContact = Contact::getById($cdata['user']);
$apContact = APContact::getByURL($publicContact['url'], false);
return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $publicContact, $apContact, $userContact);
return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $account);
}
}

View file

@ -1130,39 +1130,25 @@ class Contact
* Returns the data array for the photo menu of a given contact
*
* @param array $contact contact
* @param int $uid optional, default 0
* @param int $uid Visitor user id
* @return array
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function photoMenu(array $contact, int $uid = 0): array
public static function photoMenu(array $contact, int $uid): array
{
$pm_url = '';
// Anonymous visitor
if (!$uid) {
return ['profile' => [DI::l10n()->t('View Profile'), self::magicLinkByContact($contact), true]];
}
$pm_url = '';
$status_link = '';
$photos_link = '';
if ($uid == 0) {
$uid = DI::userSession()->getLocalUserId();
}
if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
if ($uid == 0) {
$profile_link = self::magicLinkByContact($contact);
$menu = ['profile' => [DI::l10n()->t('View Profile'), $profile_link, true]];
return $menu;
}
// Look for our own contact if the uid doesn't match and isn't public
$contact_own = DBA::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
if (DBA::isResult($contact_own)) {
return self::photoMenu($contact_own, $uid);
}
}
$sparkle = false;
if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) {
$sparkle = true;
$sparkle = true;
$profile_link = 'contact/redir/' . $contact['id'];
} else {
$profile_link = $contact['url'];
@ -1173,8 +1159,8 @@ class Contact
}
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
@ -1183,15 +1169,14 @@ class Contact
}
$contact_url = 'contact/' . $contact['id'];
$posts_link = 'contact/' . $contact['id'] . '/conversations';
$follow_link = '';
$follow_link = '';
$unfollow_link = '';
if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) {
if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
} elseif(!$contact['pending']) {
} elseif (!$contact['pending']) {
$follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
}
}
@ -1202,27 +1187,27 @@ class Contact
*/
if (empty($contact['uid'])) {
$menu = [
'profile' => [DI::l10n()->t('View Profile') , $profile_link , true],
'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true],
'unfollow'=> [DI::l10n()->t('Unfollow') , $unfollow_link, true],
'profile' => [DI::l10n()->t('View Profile') , $profile_link , true ],
'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true ],
'unfollow' => [DI::l10n()->t('Unfollow') , $unfollow_link, true ],
];
} else {
$menu = [
'status' => [DI::l10n()->t('View Status') , $status_link , true],
'profile' => [DI::l10n()->t('View Profile') , $profile_link , true],
'photos' => [DI::l10n()->t('View Photos') , $photos_link , true],
'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
'pm' => [DI::l10n()->t('Send PM') , $pm_url , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true],
'unfollow'=> [DI::l10n()->t('Unfollow') , $unfollow_link , true],
'status' => [DI::l10n()->t('View Status') , $status_link , true ],
'profile' => [DI::l10n()->t('View Profile') , $profile_link , true ],
'photos' => [DI::l10n()->t('View Photos') , $photos_link , true ],
'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
'pm' => [DI::l10n()->t('Send PM') , $pm_url , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true ],
'unfollow' => [DI::l10n()->t('Unfollow') , $unfollow_link, true ],
];
if (!empty($contact['pending'])) {
try {
$intro = DI::intro()->selectForContact($contact['id']);
$intro = DI::intro()->selectForContact($contact['id']);
$menu['follow'] = [DI::l10n()->t('Approve'), 'notifications/intros/' . $intro->id, true];
} catch (IntroductionNotFoundException $exception) {
DI::logger()->error('Pending contact doesn\'t have an introduction.', ['exception' => $exception]);
@ -1401,14 +1386,18 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::error($e->getMessage(), ['url' => $url, 'data' => $data]);
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
}
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
} catch (\InvalidArgumentException $e) {
Logger::error($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
}
}
@ -2513,14 +2502,18 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
}
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
}
}
@ -2923,15 +2916,8 @@ class Contact
}
// check if we already have a contact
// the poll url is more reliable than the profile url, as we may have
// indirect links or webfinger links
$condition = ['uid' => $uid, 'poll' => [$ret['poll'], Strings::normaliseLink($ret['poll'])], 'network' => $ret['network'], 'pending' => false];
$contact = DBA::selectFirst('contact', ['id', 'rel'], $condition);
if (!DBA::isResult($contact)) {
$condition = ['uid' => $uid, 'nurl' => Strings::normaliseLink($ret['url']), 'network' => $ret['network'], 'pending' => false];
$contact = DBA::selectFirst('contact', ['id', 'rel'], $condition);
}
$condition = ['uid' => $uid, 'nurl' => Strings::normaliseLink($ret['url'])];
$contact = DBA::selectFirst('contact', ['id', 'rel', 'url', 'pending', 'hub-verify'], $condition);
$protocol = self::getProtocol($ret['url'], $ret['network']);
@ -2987,7 +2973,13 @@ class Contact
// update contact
$new_relation = (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND]) ? self::FRIEND : self::SHARING);
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false, 'network' => $ret['network']];
if ($contact['pending'] && !empty($contact['hub-verify'])) {
ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid);
$fields['pending'] = false;
}
self::update($fields, ['id' => $contact['id']]);
} else {
$new_relation = (in_array($protocol, [Protocol::MAIL]) ? self::FRIEND : self::SHARING);

View file

@ -412,66 +412,66 @@ class Event
public static function getStrings(): array
{
// First day of the week (0 = Sunday).
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?? 0;
$defaultView = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'defaultView') ?? 'month';
$i18n = [
"firstDay" => $firstDay,
"allday" => DI::l10n()->t("all-day"),
return [
'firstDay' => $firstDay,
'defaultView' => $defaultView,
'allday' => DI::l10n()->t('all-day'),
"Sun" => DI::l10n()->t("Sun"),
"Mon" => DI::l10n()->t("Mon"),
"Tue" => DI::l10n()->t("Tue"),
"Wed" => DI::l10n()->t("Wed"),
"Thu" => DI::l10n()->t("Thu"),
"Fri" => DI::l10n()->t("Fri"),
"Sat" => DI::l10n()->t("Sat"),
'Sun' => DI::l10n()->t('Sun'),
'Mon' => DI::l10n()->t('Mon'),
'Tue' => DI::l10n()->t('Tue'),
'Wed' => DI::l10n()->t('Wed'),
'Thu' => DI::l10n()->t('Thu'),
'Fri' => DI::l10n()->t('Fri'),
'Sat' => DI::l10n()->t('Sat'),
"Sunday" => DI::l10n()->t("Sunday"),
"Monday" => DI::l10n()->t("Monday"),
"Tuesday" => DI::l10n()->t("Tuesday"),
"Wednesday" => DI::l10n()->t("Wednesday"),
"Thursday" => DI::l10n()->t("Thursday"),
"Friday" => DI::l10n()->t("Friday"),
"Saturday" => DI::l10n()->t("Saturday"),
'Sunday' => DI::l10n()->t('Sunday'),
'Monday' => DI::l10n()->t('Monday'),
'Tuesday' => DI::l10n()->t('Tuesday'),
'Wednesday' => DI::l10n()->t('Wednesday'),
'Thursday' => DI::l10n()->t('Thursday'),
'Friday' => DI::l10n()->t('Friday'),
'Saturday' => DI::l10n()->t('Saturday'),
"Jan" => DI::l10n()->t("Jan"),
"Feb" => DI::l10n()->t("Feb"),
"Mar" => DI::l10n()->t("Mar"),
"Apr" => DI::l10n()->t("Apr"),
"May" => DI::l10n()->t("May"),
"Jun" => DI::l10n()->t("Jun"),
"Jul" => DI::l10n()->t("Jul"),
"Aug" => DI::l10n()->t("Aug"),
"Sep" => DI::l10n()->t("Sept"),
"Oct" => DI::l10n()->t("Oct"),
"Nov" => DI::l10n()->t("Nov"),
"Dec" => DI::l10n()->t("Dec"),
'Jan' => DI::l10n()->t('Jan'),
'Feb' => DI::l10n()->t('Feb'),
'Mar' => DI::l10n()->t('Mar'),
'Apr' => DI::l10n()->t('Apr'),
'May' => DI::l10n()->t('May'),
'Jun' => DI::l10n()->t('Jun'),
'Jul' => DI::l10n()->t('Jul'),
'Aug' => DI::l10n()->t('Aug'),
'Sep' => DI::l10n()->t('Sept'),
'Oct' => DI::l10n()->t('Oct'),
'Nov' => DI::l10n()->t('Nov'),
'Dec' => DI::l10n()->t('Dec'),
"January" => DI::l10n()->t("January"),
"February" => DI::l10n()->t("February"),
"March" => DI::l10n()->t("March"),
"April" => DI::l10n()->t("April"),
"June" => DI::l10n()->t("June"),
"July" => DI::l10n()->t("July"),
"August" => DI::l10n()->t("August"),
"September" => DI::l10n()->t("September"),
"October" => DI::l10n()->t("October"),
"November" => DI::l10n()->t("November"),
"December" => DI::l10n()->t("December"),
'January' => DI::l10n()->t('January'),
'February' => DI::l10n()->t('February'),
'March' => DI::l10n()->t('March'),
'April' => DI::l10n()->t('April'),
'June' => DI::l10n()->t('June'),
'July' => DI::l10n()->t('July'),
'August' => DI::l10n()->t('August'),
'September' => DI::l10n()->t('September'),
'October' => DI::l10n()->t('October'),
'November' => DI::l10n()->t('November'),
'December' => DI::l10n()->t('December'),
"today" => DI::l10n()->t("today"),
"month" => DI::l10n()->t("month"),
"week" => DI::l10n()->t("week"),
"day" => DI::l10n()->t("day"),
'today' => DI::l10n()->t('today'),
'month' => DI::l10n()->t('month'),
'week' => DI::l10n()->t('week'),
'day' => DI::l10n()->t('day'),
"noevent" => DI::l10n()->t("No events to display"),
'noevent' => DI::l10n()->t('No events to display'),
"dtstart_label" => DI::l10n()->t("Starts:"),
"dtend_label" => DI::l10n()->t("Finishes:"),
"location_label" => DI::l10n()->t("Location:")
'dtstart_label' => DI::l10n()->t('Starts:'),
'dtend_label' => DI::l10n()->t('Finishes:'),
'location_label' => DI::l10n()->t('Location:')
];
return $i18n;
}
/**

View file

@ -167,27 +167,43 @@ class GServer
/**
* Checks if the given server is reachable
*
* @param string $profile URL of the given profile
* @param string $server URL of the given server (If empty, taken from profile)
* @param string $network Network value that is used, when detection failed
* @param boolean $force Force an update.
* @param array $contact Contact that should be checked
*
* @return boolean 'true' if server seems vital
*/
public static function reachable(string $profile, string $server = '', string $network = '', bool $force = false): bool
public static function reachable(array $contact): bool
{
if ($server == '') {
$contact = Contact::getByURL($profile, null, ['baseurl']);
if (!empty($contact['baseurl'])) {
$server = $contact['baseurl'];
}
}
if ($server == '') {
if (!empty($contact['gsid'])) {
$gsid = $contact['gsid'];
} elseif (!empty($contact['baseurl'])) {
$server = $contact['baseurl'];
} elseif ($contact['network'] == Protocol::DIASPORA) {
$parts = parse_url($contact['url']);
unset($parts['path']);
$server = (string)Uri::fromParts($parts);
} else {
return true;
}
return self::check($server, $network, $force);
if (!empty($gsid)) {
$condition = ['id' => $gsid];
} else {
$condition = ['nurl' => Strings::normaliseLink($server)];
}
$gserver = DBA::selectFirst('gserver', ['url', 'next_contact', 'failed'], $condition);
if (empty($gserver)) {
$reachable = true;
} else {
$reachable = !$gserver['failed'];
$server = $gserver['url'];
}
if (!empty($server) && (empty($gserver) || strtotime($gserver['next_contact']) < time())) {
Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $server, false);
}
return $reachable;
}
/**

View file

@ -3030,6 +3030,7 @@ class Item
$shared = DI::contentItem()->getSharedPost($item, $fields);
if (!empty($shared['post'])) {
$shared_item = $shared['post'];
$shared_item['body'] = Post\Media::removeFromEndOfBody($shared_item['body']);
$quote_uri_id = $shared['post']['uri-id'];
$shared_links[] = strtolower($shared['post']['uri']);
$item['body'] = BBCode::removeSharedData($item['body']);

View file

@ -388,10 +388,6 @@ class Site extends BaseAdmin
/* Banner */
$banner = DI::config()->get('system', 'banner');
if ($banner == false) {
$banner = '<a href="https://friendi.ca"><img id="logo-img" width="32" height="32" src="images/friendica.svg" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
}
$email_banner = DI::config()->get('system', 'email_banner');
if ($email_banner == false) {

View file

@ -35,6 +35,7 @@ use Friendica\DI;
use Friendica\Model;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
/**
@ -494,16 +495,18 @@ class Contact extends BaseModule
*
* @param array $contact Contact array
* @return array Template fields
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getContactTemplateVars(array $contact)
public static function getContactTemplateVars(array $contact): array
{
$alt_text = '';
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && DI::userSession()->getLocalUserId()) {
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], DI::userSession()->getLocalUserId());
if (!empty($personal)) {
$contact['uid'] = $personal['uid'];
$contact['rel'] = $personal['rel'];
$contact['uid'] = $personal['uid'];
$contact['rel'] = $personal['rel'];
$contact['self'] = $personal['self'];
}
}
@ -545,15 +548,15 @@ class Contact extends BaseModule
if ($contact['self']) {
$alt_text = DI::l10n()->t('This is you');
$url = $contact['url'];
$sparkle = '';
$url = $contact['url'];
$sparkle = '';
}
return [
'id' => $contact['id'],
'url' => $url,
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
'photo_menu' => Model\Contact::photoMenu($contact),
'photo_menu' => Model\Contact::photoMenu($contact, DI::userSession()->getLocalUserId()),
'thumb' => Model\Contact::getThumb($contact, true),
'alt_text' => $alt_text,
'name' => $contact['name'],

View file

@ -21,54 +21,72 @@
namespace Friendica\Module\Contact;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Pager;
use Friendica\Content\Widget;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Model;
use Friendica\Model\User;
use Friendica\Module;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
class Contacts extends BaseModule
{
/** @var IHandleUserSessions */
private $userSession;
/** @var App\Page */
private $page;
public function __construct(App\Page $page, IHandleUserSessions $userSession, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->userSession = $userSession;
$this->page = $page;
}
protected function content(array $request = []): string
{
if (!DI::userSession()->getLocalUserId()) {
if (!$this->userSession->getLocalUserId()) {
throw new HTTPException\ForbiddenException();
}
$cid = $this->parameters['id'];
$type = $this->parameters['type'] ?? 'all';
$accounttype = $_GET['accounttype'] ?? '';
$accounttype = $request['accounttype'] ?? '';
$accounttypeid = User::getAccountTypeByString($accounttype);
if (!$cid) {
throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
throw new HTTPException\BadRequestException($this->t('Invalid contact.'));
}
$contact = Model\Contact::getById($cid, []);
if (empty($contact)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
}
$localContactId = Model\Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
$localContactId = Model\Contact::getPublicIdByUserId($this->userSession->getLocalUserId());
DI::page()['aside'] = Widget\VCard::getHTML($contact);
$this->page['aside'] = Widget\VCard::getHTML($contact);
$condition = [
'blocked' => false,
'self' => false,
'hidden' => false,
'failed' => false,
'self' => false,
'hidden' => false,
'failed' => false,
];
if (isset($accounttypeid)) {
$condition['contact-type'] = $accounttypeid;
}
$noresult_label = DI::l10n()->t('No known contacts.');
$noresult_label = $this->t('No known contacts.');
switch ($type) {
case 'followers':
@ -82,50 +100,61 @@ class Contacts extends BaseModule
break;
case 'common':
$total = Model\Contact\Relation::countCommon($localContactId, $cid, $condition);
$noresult_label = DI::l10n()->t('No common contacts.');
$noresult_label = $this->t('No common contacts.');
break;
default:
$total = Model\Contact\Relation::countAll($cid, $condition);
}
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
$pager = new Pager($this->l10n, $this->args->getQueryString(), 30);
$desc = '';
switch ($type) {
case 'followers':
$friends = Model\Contact\Relation::listFollowers($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
$title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
$title = $this->tt('Follower (%s)', 'Followers (%s)', $total);
break;
case 'following':
$friends = Model\Contact\Relation::listFollows($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
$title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
$title = $this->tt('Following (%s)', 'Following (%s)', $total);
break;
case 'mutuals':
$friends = Model\Contact\Relation::listMutuals($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
$desc = DI::l10n()->t(
$title = $this->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
$desc = $this->t(
'These contacts both follow and are followed by <strong>%s</strong>.',
htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
);
break;
case 'common':
$friends = Model\Contact\Relation::listCommon($localContactId, $cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = DI::l10n()->t(
$title = $this->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = $this->t(
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
);
break;
default:
$friends = Model\Contact\Relation::listAll($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
$title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
$title = $this->tt('Contact (%s)', 'Contacts (%s)', $total);
}
$o = Module\Contact::getTabsHTML($contact, Module\Contact::TAB_CONTACTS);
$tabs = self::getContactFilterTabs('contact/' . $cid, $type, true);
$contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $friends);
// Contact list is obtained from the visited contact, but the contact display is visitor dependent
$contacts = array_map(
function ($contact) {
$contact = Model\Contact::selectFirst(
[],
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
['order' => ['uid' => 'DESC']]
);
return Module\Contact::getContactTemplateVars($contact);
},
$friends
);
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
$o .= Renderer::replaceMacros($tpl, [
@ -139,7 +168,7 @@ class Contacts extends BaseModule
'$paginate' => $pager->renderFull($total),
]);
DI::page()['aside'] .= Widget::accountTypes($_SERVER['REQUEST_URI'], $accounttype);
$this->page['aside'] .= Widget::accountTypes($_SERVER['REQUEST_URI'], $accounttype);
return $o;
}

View file

@ -21,26 +21,45 @@
namespace Friendica\Module\Contact;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
/**
* Asynchronous HTML fragment provider for frio contact hovercards
*/
class Hovercard extends BaseModule
{
/** @var IManageConfigValues */
private $config;
/** @var IHandleUserSessions */
private $userSession;
public function __construct(IHandleUserSessions $userSession, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config;
$this->userSession = $userSession;
}
protected function rawContent(array $request = [])
{
$contact_url = $_REQUEST['url'] ?? '';
$contact_url = $request['url'] ?? '';
// Get out if the system doesn't have public access allowed
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
if ($this->config->get('system', 'block_public') && !$this->userSession->isAuthenticated()) {
throw new HTTPException\ForbiddenException();
}
@ -50,7 +69,7 @@ class Hovercard extends BaseModule
*/
if (strpos($contact_url, 'contact/') === 0 && preg_match('/(\d+)/', $contact_url, $matches)) {
$remote_contact = Contact::selectFirst(['nurl'], ['id' => $matches[1]]);
$contact_url = $remote_contact['nurl'] ?? '';
$contact_url = $remote_contact['nurl'] ?? '';
}
if (!$contact_url) {
@ -59,8 +78,8 @@ class Hovercard extends BaseModule
// Search for contact data
// Look if the local user has got the contact
if (DI::userSession()->isAuthenticated()) {
$contact = Contact::getByURLForUser($contact_url, DI::userSession()->getLocalUserId());
if ($this->userSession->isAuthenticated()) {
$contact = Contact::getByURLForUser($contact_url, $this->userSession->getLocalUserId());
} else {
$contact = Contact::getByURL($contact_url, false);
}
@ -70,15 +89,15 @@ class Hovercard extends BaseModule
}
// Get the photo_menu - the menu if possible contact actions
if (DI::userSession()->isAuthenticated()) {
$actions = Contact::photoMenu($contact);
if ($this->userSession->isAuthenticated()) {
$actions = Contact::photoMenu($contact, $this->userSession->getLocalUserId());
} else {
$actions = [];
}
// Move the contact data to the profile array so we can deliver it to
$tpl = Renderer::getMarkupTemplate('hovercard.tpl');
$o = Renderer::replaceMacros($tpl, [
$o = Renderer::replaceMacros($tpl, [
'$profile' => [
'name' => $contact['name'],
'nick' => $contact['nick'],
@ -96,7 +115,6 @@ class Hovercard extends BaseModule
],
]);
echo $o;
System::exit();
System::httpExit($o);
}
}

View file

@ -21,51 +21,71 @@
namespace Friendica\Module\Profile;
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
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\Module;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\BaseProfile;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
class Common extends BaseProfile
{
/** @var IManageConfigValues */
private $config;
/** @var IHandleUserSessions */
private $userSession;
/** @var App */
private $app;
public function __construct(App $app, IHandleUserSessions $userSession, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config;
$this->userSession = $userSession;
$this->app = $app;
}
protected function content(array $request = []): string
{
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
if ($this->config->get('system', 'block_public') && !$this->userSession->isAuthenticated()) {
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
$a = DI::app();
Nav::setSelected('home');
$nickname = $this->parameters['nickname'];
$profile = Profile::load($a, $nickname);
$profile = Profile::load($this->app, $nickname);
if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
if (!empty($profile['hide-friends'])) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
}
$displayCommonTab = DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId();
$displayCommonTab = $this->userSession->isAuthenticated() && $profile['uid'] != $this->userSession->getLocalUserId();
if (!$displayCommonTab) {
$a->redirect('profile/' . $nickname . '/contacts');
$this->baseUrl->redirect('profile/' . $nickname . '/contacts');
};
$o = self::getTabsHTML('contacts', false, $profile['nickname'], $profile['hide-friends']);
$tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
$sourceId = Contact::getIdForURL(Profile::getMyURL());
$sourceId = Contact::getIdForURL($this->userSession->getMyUrl());
$targetId = Contact::getPublicIdByUserId($profile['uid']);
$condition = [
@ -76,14 +96,25 @@ class Common extends BaseProfile
$total = Contact\Relation::countCommon($sourceId, $targetId, $condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
$pager = new Pager($this->l10n, $this->args->getQueryString(), 30);
$commonFollows = Contact\Relation::listCommon($sourceId, $targetId, $condition, $pager->getItemsPerPage(), $pager->getStart());
$contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $commonFollows);
// Contact list is obtained from the visited profile user, but the contact display is visitor dependent
$contacts = array_map(
function ($contact) {
$contact = Contact::selectFirst(
[],
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
['order' => ['uid' => 'DESC']]
);
return Module\Contact::getContactTemplateVars($contact);
},
$commonFollows
);
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = DI::l10n()->t(
$title = $this->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = $this->t(
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
);
@ -94,7 +125,7 @@ class Common extends BaseProfile
'$desc' => $desc,
'$tabs' => $tabs,
'$noresult_label' => DI::l10n()->t('No common contacts.'),
'$noresult_label' => $this->t('No common contacts.'),
'$contacts' => $contacts,
'$paginate' => $pager->renderFull($total),

View file

@ -21,45 +21,68 @@
namespace Friendica\Module\Profile;
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database;
use Friendica\Model;
use Friendica\Module;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
class Contacts extends Module\BaseProfile
{
/** @var IManageConfigValues */
private $config;
/** @var IHandleUserSessions */
private $userSession;
/** @var App */
private $app;
/** @var Database */
private $database;
public function __construct(Database $database, App $app, IHandleUserSessions $userSession, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config;
$this->userSession = $userSession;
$this->app = $app;
$this->database = $database;
}
protected function content(array $request = []): string
{
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
if ($this->config->get('system', 'block_public') && !$this->userSession->isAuthenticated()) {
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
$a = DI::app();
$nickname = $this->parameters['nickname'];
$type = $this->parameters['type'] ?? 'all';
$type = $this->parameters['type'] ?? 'all';
$profile = Model\Profile::load($a, $nickname);
$profile = Model\Profile::load($this->app, $nickname);
if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
$is_owner = $profile['uid'] == DI::userSession()->getLocalUserId();
$is_owner = $profile['uid'] == $this->userSession->getLocalUserId();
if ($profile['hide-friends'] && !$is_owner) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
}
Nav::setSelected('home');
$o = self::getTabsHTML('contacts', $is_owner, $profile['nickname'], $profile['hide-friends']);
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId());
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, $this->userSession->isAuthenticated() && $profile['uid'] != $this->userSession->getLocalUserId());
$condition = [
'uid' => $profile['uid'],
@ -73,50 +96,64 @@ class Contacts extends Module\BaseProfile
];
switch ($type) {
case 'followers': $condition['rel'] = [Model\Contact::FOLLOWER, Model\Contact::FRIEND]; break;
case 'following': $condition['rel'] = [Model\Contact::SHARING, Model\Contact::FRIEND]; break;
case 'mutuals': $condition['rel'] = Model\Contact::FRIEND; break;
case 'followers':
$condition['rel'] = [Model\Contact::FOLLOWER, Model\Contact::FRIEND];
break;
case 'following':
$condition['rel'] = [Model\Contact::SHARING, Model\Contact::FRIEND];
break;
case 'mutuals':
$condition['rel'] = Model\Contact::FRIEND;
break;
}
$total = DBA::count('contact', $condition);
$total = $this->database->count('contact', $condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
$pager = new Pager($this->l10n, $this->args->getQueryString(), 30);
$params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
// Contact list is obtained from the visited profile user, but the contact display is visitor dependent
$contacts = array_map(
[Module\Contact::class, 'getContactTemplateVars'],
Model\Contact::selectToArray([], $condition, $params)
function ($contact) {
$contact = Model\Contact::selectFirst(
[],
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
['order' => ['uid' => 'DESC']]
);
return Module\Contact::getContactTemplateVars($contact);
},
Model\Contact::selectToArray(['uri-id'], $condition, $params)
);
$desc = '';
switch ($type) {
case 'followers':
$title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
$title = $this->tt('Follower (%s)', 'Followers (%s)', $total);
break;
case 'following':
$title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
$title = $this->tt('Following (%s)', 'Following (%s)', $total);
break;
case 'mutuals':
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
$desc = DI::l10n()->t(
$title = $this->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
$desc = $this->t(
'These contacts both follow and are followed by <strong>%s</strong>.',
htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
);
break;
case 'all':
default:
$title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
$title = $this->tt('Contact (%s)', 'Contacts (%s)', $total);
break;
}
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$title' => $title,
'$desc' => $desc,
'$tabs' => $tabs,
$o .= Renderer::replaceMacros($tpl, [
'$title' => $title,
'$desc' => $desc,
'$tabs' => $tabs,
'$noresult_label' => DI::l10n()->t('No contacts.'),
'$noresult_label' => $this->t('No contacts.'),
'$contacts' => $contacts,
'$paginate' => $pager->renderFull($total),

View file

@ -21,8 +21,19 @@
namespace Friendica\Module\Profile;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Conversation;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database;
use Friendica\Module\Response;
use Friendica\Profile\ProfileField\Repository\ProfileField;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
/**
* Profile index router
@ -35,13 +46,50 @@ use Friendica\Core\L10n;
*/
class Index extends BaseModule
{
/** @var Database */
private $database;
/** @var App */
private $app;
/** @var IHandleUserSessions */
private $session;
/** @var IManageConfigValues */
private $config;
/** @var App\Page */
private $page;
/** @var ProfileField */
private $profileField;
/** @var DateTimeFormat */
private $dateTimeFormat;
/** @var Conversation */
private $conversation;
/** @var IManagePersonalConfigValues */
private $pConfig;
/** @var App\Mode */
private $mode;
public function __construct(App\Mode $mode, IManagePersonalConfigValues $pConfig, Conversation $conversation, DateTimeFormat $dateTimeFormat, ProfileField $profileField, App\Page $page, IManageConfigValues $config, IHandleUserSessions $session, App $app, Database $database, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->database = $database;
$this->app = $app;
$this->session = $session;
$this->config = $config;
$this->page = $page;
$this->profileField = $profileField;
$this->dateTimeFormat = $dateTimeFormat;
$this->conversation = $conversation;
$this->pConfig = $pConfig;
$this->mode = $mode;
}
protected function rawContent(array $request = [])
{
(new Profile($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->rawContent();
(new Profile($this->profileField, $this->page, $this->config, $this->session, $this->app, $this->database, $this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->rawContent();
}
protected function content(array $request = []): string
{
return (new Status($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->content();
return (new Status($this->mode, $this->pConfig, $this->conversation, $this->session, $this->config, $this->dateTimeFormat, $this->page, $this->app, $this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->content();
}
}

View file

@ -78,7 +78,7 @@ class Photos extends \Friendica\Module\BaseProfile
$this->systemMessages = $systemMessages;
$this->aclFormatter = $aclFormatter;
$owner = Profile::load($this->app, $this->parameters['nickname'] ?? '');
$owner = Profile::load($this->app, $this->parameters['nickname'] ?? '', false);
if (!$owner || $owner['account_removed'] || $owner['account_expired']) {
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
@ -318,16 +318,8 @@ class Photos extends \Friendica\Module\BaseProfile
$owner_uid = $this->owner['uid'];
$is_owner = $this->session->getLocalUserId() == $owner_uid;
$remote_contact = false;
if ($this->session->getRemoteContactID($owner_uid)) {
$contact_id = $this->session->getRemoteContactID($owner_uid);
$contact = Contact::getContactForUser($contact_id, $owner_uid, ['blocked', 'pending']);
$remote_contact = $contact && !$contact['blocked'] && !$contact['pending'];
}
if ($this->owner['hidewall'] && !$this->session->isAuthenticated()) {
$this->baseUrl->redirect('profile/' . $owner['nickname'] . '/restricted');
$this->baseUrl->redirect('profile/' . $this->owner['nickname'] . '/restricted');
}
$this->session->set('photo_return', $this->args->getCommand());
@ -412,6 +404,11 @@ class Photos extends \Friendica\Module\BaseProfile
]);
}
// Removing vCard for owner
if ($is_owner) {
$this->page['aside'] = '';
}
if (!empty($photo_albums_widget)) {
$this->page['aside'] .= $photo_albums_widget;
}

View file

@ -21,35 +21,68 @@
namespace Friendica\Module\Profile;
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile as ProfileModel;
use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Module\BaseProfile;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException;
use Friendica\Profile\ProfileField\Repository\ProfileField;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Psr\Log\LoggerInterface;
class Profile extends BaseProfile
{
/** @var Database */
private $database;
/** @var App */
private $app;
/** @var IHandleUserSessions */
private $session;
/** @var IManageConfigValues */
private $config;
/** @var App\Page */
private $page;
/** @var ProfileField */
private $profileField;
public function __construct(ProfileField $profileField, App\Page $page, IManageConfigValues $config, IHandleUserSessions $session, App $app, Database $database, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->database = $database;
$this->app = $app;
$this->session = $session;
$this->config = $config;
$this->page = $page;
$this->profileField = $profileField;
}
protected function rawContent(array $request = [])
{
if (ActivityPub::isRequest()) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'], 'account_removed' => false]);
if (DBA::isResult($user)) {
$user = $this->database->selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'] ?? '', 'account_removed' => false]);
if ($user) {
try {
$data = ActivityPub\Transmitter::getProfile($user['uid']);
header('Access-Control-Allow-Origin: *');
@ -60,7 +93,7 @@ class Profile extends BaseProfile
}
}
if (DBA::exists('userd', ['username' => $this->parameters['nickname']])) {
if ($this->database->exists('userd', ['username' => $this->parameters['nickname']])) {
// Known deleted user
$data = ActivityPub\Transmitter::getDeletedUser($this->parameters['nickname']);
@ -74,43 +107,41 @@ class Profile extends BaseProfile
protected function content(array $request = []): string
{
$a = DI::app();
$profile = ProfileModel::load($a, $this->parameters['nickname'] ?? '');
$profile = ProfileModel::load($this->app, $this->parameters['nickname'] ?? '');
if (!$profile) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
throw new HTTPException\NotFoundException($this->t('Profile not found.'));
}
$remote_contact_id = DI::userSession()->getRemoteContactID($profile['uid']);
$remote_contact_id = $this->session->getRemoteContactID($profile['uid']);
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
if ($this->config->get('system', 'block_public') && !$this->session->isAuthenticated()) {
return Login::form();
}
if (!empty($profile['hidewall']) && !DI::userSession()->isAuthenticated()) {
if (!empty($profile['hidewall']) && !$this->session->isAuthenticated()) {
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
}
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
$this->page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
}
DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $this->parameters['nickname'], $remote_contact_id);
$this->page['htmlhead'] .= $this->buildHtmlHead($profile, $this->parameters['nickname']);
Nav::setSelected('home');
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
$o = self::getTabsHTML('profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
$is_owner = $this->session->getLocalUserId() == $profile['uid'];
$o = self::getTabsHTML('profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
$view_as_contacts = [];
$view_as_contact_id = 0;
$view_as_contacts = [];
$view_as_contact_id = 0;
$view_as_contact_alert = '';
if ($is_owner) {
$view_as_contact_id = intval($_GET['viewas'] ?? 0);
$view_as_contact_id = intval($request['viewas'] ?? 0);
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
'uid' => DI::userSession()->getLocalUserId(),
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
'uid' => $this->session->getLocalUserId(),
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
'network' => Protocol::DFRN,
'blocked' => false,
]);
@ -123,7 +154,7 @@ class Profile extends BaseProfile
}
if (($key = array_search($view_as_contact_id, $view_as_contact_ids)) !== false) {
$view_as_contact_alert = DI::l10n()->t(
$view_as_contact_alert = $this->t(
'You\'re currently viewing your profile as <b>%s</b> <a href="%s" class="btn btn-sm pull-right">Cancel</a>',
htmlentities($view_as_contacts[$key]['name'], ENT_COMPAT, 'UTF-8'),
'profile/' . $this->parameters['nickname'] . '/profile'
@ -133,47 +164,51 @@ class Profile extends BaseProfile
$basic_fields = [];
$basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $profile['name']);
$basic_fields += self::buildField('fullname', $this->t('Full Name:'), $profile['name']);
if (Feature::isEnabled($profile['uid'], 'profile_membersince')) {
$basic_fields += self::buildField(
'membersince',
DI::l10n()->t('Member since:'),
$this->t('Member since:'),
DateTimeFormat::local($profile['register_date'])
);
}
if (!empty($profile['dob']) && $profile['dob'] > DBA::NULL_DATE) {
$year_bd_format = DI::l10n()->t('j F, Y');
$short_bd_format = DI::l10n()->t('j F');
$year_bd_format = $this->t('j F, Y');
$short_bd_format = $this->t('j F');
$dob = DI::l10n()->getDay(
$dob = $this->l10n->getDay(
intval($profile['dob']) ?
DateTimeFormat::utc($profile['dob'] . ' 00:00 +00:00', $year_bd_format)
: DateTimeFormat::utc('2001-' . substr($profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
);
$basic_fields += self::buildField('dob', DI::l10n()->t('Birthday:'), $dob);
$basic_fields += self::buildField('dob', $this->t('Birthday:'), $dob);
if ($age = Temporal::getAgeByTimezone($profile['dob'], $profile['timezone'])) {
$basic_fields += self::buildField('age', DI::l10n()->t('Age: '), DI::l10n()->tt('%d year old', '%d years old', $age));
$basic_fields += self::buildField('age', $this->t('Age: '), $this->tt('%d year old', '%d years old', $age));
}
}
if ($profile['about']) {
$basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
$basic_fields += self::buildField('about', $this->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
}
if ($profile['xmpp']) {
$basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $profile['xmpp']);
$basic_fields += self::buildField('xmpp', $this->t('XMPP:'), $profile['xmpp']);
}
if ($profile['matrix']) {
$basic_fields += self::buildField('matrix', DI::l10n()->t('Matrix:'), $profile['matrix']);
$basic_fields += self::buildField('matrix', $this->t('Matrix:'), $profile['matrix']);
}
if ($profile['homepage']) {
$basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($profile['homepage']));
$basic_fields += self::buildField(
'homepage',
$this->t('Homepage:'),
$this->tryRelMe($profile['homepage']) ?: $profile['homepage']
);
}
if (
@ -183,7 +218,7 @@ class Profile extends BaseProfile
|| $profile['region']
|| $profile['country-name']
) {
$basic_fields += self::buildField('location', DI::l10n()->t('Location:'), ProfileModel::formatLocation($profile));
$basic_fields += self::buildField('location', $this->t('Location:'), ProfileModel::formatLocation($profile));
}
if ($profile['pub_keywords']) {
@ -191,12 +226,12 @@ class Profile extends BaseProfile
// Separator is defined in Module\Settings\Profile\Index::cleanKeywords
foreach (explode(', ', $profile['pub_keywords']) as $tag_label) {
$tags[] = [
'url' => '/search?tag=' . $tag_label,
'url' => '/search?tag=' . $tag_label,
'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label,
];
}
$basic_fields += self::buildField('pub_keywords', DI::l10n()->t('Tags:'), $tags);
$basic_fields += self::buildField('pub_keywords', $this->t('Tags:'), $tags);
}
$custom_fields = [];
@ -205,54 +240,54 @@ class Profile extends BaseProfile
$contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0;
if ($is_owner && $contact_id === 0) {
$profile_fields = DI::profileField()->selectByUserId($profile['uid']);
$profile_fields = $this->profileField->selectByUserId($profile['uid']);
} else {
$profile_fields = DI::profileField()->selectByContactId($contact_id, $profile['uid']);
$profile_fields = $this->profileField->selectByContactId($contact_id, $profile['uid']);
}
foreach ($profile_fields as $profile_field) {
$custom_fields += self::buildField(
'custom_' . $profile_field->order,
$profile_field->label,
BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
$this->tryRelMe($profile_field->value) ?: BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
'aprofile custom'
);
};
}
//show subcribed forum if it is enabled in the usersettings
if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
$custom_fields += self::buildField(
'forumlist',
DI::l10n()->t('Forums:'),
$this->t('Forums:'),
ForumManager::profileAdvanced($profile['uid'])
);
}
$tpl = Renderer::getMarkupTemplate('profile/profile.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Profile'),
'$yourself' => DI::l10n()->t('Yourself'),
'$view_as_contacts' => $view_as_contacts,
'$view_as_contact_id' => $view_as_contact_id,
$o .= Renderer::replaceMacros($tpl, [
'$title' => $this->t('Profile'),
'$yourself' => $this->t('Yourself'),
'$view_as_contacts' => $view_as_contacts,
'$view_as_contact_id' => $view_as_contact_id,
'$view_as_contact_alert' => $view_as_contact_alert,
'$view_as' => DI::l10n()->t('View profile as:'),
'$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'),
'$is_owner' => $profile['uid'] == DI::userSession()->getLocalUserId(),
'$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields,
'$profile' => $profile,
'$edit_link' => [
'url' => DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'),
'$view_as' => $this->t('View profile as:'),
'$submit' => $this->t('Submit'),
'$basic' => $this->t('Basic'),
'$advanced' => $this->t('Advanced'),
'$is_owner' => $profile['uid'] == $this->session->getLocalUserId(),
'$query_string' => $this->args->getQueryString(),
'$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields,
'$profile' => $profile,
'$edit_link' => [
'url' => 'settings/profile', $this->t('Edit profile'),
'title' => '',
'label' => DI::l10n()->t('Edit profile')
'label' => $this->t('Edit profile')
],
'$viewas_link' => [
'url' => DI::args()->getQueryString() . '#viewas',
'$viewas_link' => [
'url' => $this->args->getQueryString() . '#viewas',
'title' => '',
'label' => DI::l10n()->t('View as')
'label' => $this->t('View as')
],
]);
@ -270,20 +305,18 @@ class Profile extends BaseProfile
* @param string $class Optional CSS class to apply to the field
* @return array
*/
private static function buildField(string $name, string $label, $value, string $class = 'aprofile')
private static function buildField(string $name, string $label, $value, string $class = 'aprofile'): array
{
return [$name => [
'id' => 'aprofile-' . $name,
'id' => 'aprofile-' . $name,
'class' => $class,
'label' => $label,
'value' => $value,
]];
}
private static function buildHtmlHead(array $profile, string $nickname, int $remote_contact_id)
private function buildHtmlHead(array $profile, string $nickname): string
{
$baseUrl = DI::baseUrl();
$htmlhead = "\n";
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
@ -300,8 +333,8 @@ class Profile extends BaseProfile
}
// site block
$blocked = !DI::userSession()->isAuthenticated() && DI::config()->get('system', 'block_public');
$userblock = !DI::userSession()->isAuthenticated() && $profile['hidewall'];
$blocked = !$this->session->isAuthenticated() && $this->config->get('system', 'block_public');
$userblock = !$this->session->isAuthenticated() && $profile['hidewall'];
if (!$blocked && !$userblock) {
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
if (strlen($keywords)) {
@ -315,19 +348,34 @@ class Profile extends BaseProfile
$htmlhead .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
header('Link: <' . $baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : ''));
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $this->baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
header('Link: <' . $this->baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
foreach ($dfrn_pages as $dfrn) {
$htmlhead .= '<link rel="dfrn-' . $dfrn . '" href="' . $baseUrl . '/dfrn_' . $dfrn . '/' . $nickname . '" />' . "\n";
$htmlhead .= '<link rel="dfrn-' . $dfrn . '" href="' . $this->baseUrl . '/dfrn_' . $dfrn . '/' . $nickname . '" />' . "\n";
}
return $htmlhead;
}
/**
* Check if the input is an HTTP(S) link and returns a rel="me" link if yes, empty string if not
*
* @param string $input
* @return string
*/
private function tryRelMe(string $input): string
{
if (preg_match(Strings::onlyLinkRegEx(), trim($input))) {
return '<a href="' . trim($input) . '" target="_blank" rel="noopener noreferrer me">' . trim($input) . '</a>';
}
return '';
}
}

View file

@ -21,13 +21,18 @@
namespace Friendica\Module\Profile;
use Friendica\App;
use Friendica\Content\Conversation;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
@ -36,150 +41,176 @@ use Friendica\Model\Profile as ProfileModel;
use Friendica\Model\User;
use Friendica\Model\Verb;
use Friendica\Module\BaseProfile;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Security\Security;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Friendica\Util\XML;
use Psr\Log\LoggerInterface;
class Status extends BaseProfile
{
/** @var App */
private $app;
/** @var App\Page */
private $page;
/** @var DateTimeFormat */
private $dateTimeFormat;
/** @var IManageConfigValues */
private $config;
/** @var IHandleUserSessions */
private $session;
/** @var Conversation */
private $conversation;
/** @var IManagePersonalConfigValues */
private $pConfig;
/** @var App\Mode */
private $mode;
public function __construct(App\Mode $mode, IManagePersonalConfigValues $pConfig, Conversation $conversation, IHandleUserSessions $session, IManageConfigValues $config, DateTimeFormat $dateTimeFormat, App\Page $page, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->app = $app;
$this->page = $page;
$this->dateTimeFormat = $dateTimeFormat;
$this->config = $config;
$this->session = $session;
$this->conversation = $conversation;
$this->pConfig = $pConfig;
$this->mode = $mode;
}
protected function content(array $request = []): string
{
$args = DI::args();
$a = DI::app();
$profile = ProfileModel::load($a, $this->parameters['nickname']);
$profile = ProfileModel::load($this->app, $this->parameters['nickname'] ?? '');
if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
if ($this->config->get('system', 'block_public') && !$this->session->isAuthenticated()) {
return Login::form();
}
if (!empty($profile['hidewall']) && !$this->session->isAuthenticated()) {
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
}
if (!$profile['net-publish']) {
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
$this->page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $this->parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $this->parameters['nickname'] . '" title="DFRN: ' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $this->parameters['nickname'] . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $this->parameters['nickname'] . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $this->parameters['nickname'] . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$category = $datequery = $datequery2 = '';
$dtFormat = DI::dtFormat();
if ($args->getArgc() > 3) {
for ($x = 3; $x < $args->getArgc(); $x++) {
if ($dtFormat->isYearMonthDay($args->get($x))) {
if ($this->args->getArgc() > 3) {
for ($x = 3; $x < $this->args->getArgc(); $x++) {
if ($this->dateTimeFormat->isYearMonthDay($this->args->get($x))) {
if ($datequery) {
$datequery2 = Strings::escapeHtml($args->get($x));
$datequery2 = $this->args->get($x);
} else {
$datequery = Strings::escapeHtml($args->get($x));
$datequery = $this->args->get($x);
}
} else {
$category = $args->get($x);
$category = $this->args->get($x);
}
}
}
if (empty($category)) {
$category = $_GET['category'] ?? '';
$category = $request['category'] ?? '';
}
$hashtags = $_GET['tag'] ?? '';
if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($profile['uid'])) {
return Login::form();
}
$hashtags = $request['tag'] ?? '';
$o = '';
if ($profile['uid'] == DI::userSession()->getLocalUserId()) {
if ($profile['uid'] == $this->session->getLocalUserId()) {
Nav::setSelected('home');
}
$remote_contact = DI::userSession()->getRemoteContactID($profile['uid']);
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
$last_updated_key = "profile:" . $profile['uid'] . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
if (!empty($profile['hidewall']) && !DI::userSession()->isAuthenticated()) {
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
}
$remote_contact = $this->session->getRemoteContactID($profile['uid']);
$is_owner = $this->session->getLocalUserId() == $profile['uid'];
$last_updated_key = "profile:" . $profile['uid'] . ":" . $this->session->getLocalUserId() . ":" . $remote_contact;
$o .= self::getTabsHTML('status', $is_owner, $profile['nickname'], $profile['hide-friends']);
$o .= Widget::commonFriendsVisitor($profile['uid'], $profile['nickname']);
$commpage = $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
$commpage = $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
$commvisitor = $commpage && $remote_contact;
DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $profile['profile_uid'] ?? 0, true);
DI::page()['aside'] .= Widget::categories($profile['uid'], DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $category);
DI::page()['aside'] .= Widget::tagCloud($profile['uid']);
$this->page['aside'] .= Widget::postedByYear($this->baseUrl . '/profile/' . $profile['nickname'] . '/status', $profile['profile_uid'] ?? 0, true);
$this->page['aside'] .= Widget::categories($profile['uid'], $this->baseUrl . '/profile/' . $profile['nickname'] . '/status', $category);
$this->page['aside'] .= Widget::tagCloud($profile['uid']);
if (Security::canWriteToUserWall($profile['uid'])) {
$x = [
'is_owner' => $is_owner,
'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'],
'is_owner' => $is_owner,
'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'],
'default_location' => $is_owner ? $profile['default-location'] : '',
'nickname' => $profile['nickname'],
'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), true) : '',
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $profile['uid'],
'nickname' => $profile['nickname'],
'acl' => $is_owner ? ACL::getFullSelectorHTML($this->page, $this->app->getLoggedInUserId(), true) : '',
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $profile['uid'],
];
$o .= DI::conversation()->statusEditor($x);
$o .= $this->conversation->statusEditor($x);
}
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
$condition = Item::getPermissionsConditionArrayByUserId($profile['uid']);
$last_updated_array = DI::session()->get('last_updated', []);
$last_updated_array = $this->session->get('last_updated', []);
if (!empty($category)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `category-view` WHERE `name` = ? AND `type` = ? AND `uid` = ?)",
$category, Category::CATEGORY, $profile['uid']]);
$category, Category::CATEGORY, $profile['uid']]);
}
if (!empty($hashtags)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `tag-search-view` WHERE `name` = ? AND `uid` = ?)",
$hashtags, $profile['uid']]);
$hashtags, $profile['uid']]);
}
if (!empty($datequery)) {
$condition = DBA::mergeConditions($condition, ["`received` <= ?", DateTimeFormat::convert($datequery, 'UTC', $a->getTimeZone())]);
$condition = DBA::mergeConditions($condition, ["`received` <= ?", DateTimeFormat::convert($datequery, 'UTC', $this->app->getTimeZone())]);
}
if (!empty($datequery2)) {
$condition = DBA::mergeConditions($condition, ["`received` >= ?", DateTimeFormat::convert($datequery2, 'UTC', $a->getTimeZone())]);
$condition = DBA::mergeConditions($condition, ["`received` >= ?", DateTimeFormat::convert($datequery2, 'UTC', $this->app->getTimeZone())]);
}
// Does the profile page belong to a forum?
// If not then we can improve the performance with an additional condition
$condition2 = ['uid' => $profile['uid'], 'account-type' => User::ACCOUNT_TYPE_COMMUNITY];
if (!DBA::exists('user', $condition2)) {
if ($profile['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
$condition = DBA::mergeConditions($condition, ['contact-id' => $profile['id']]);
}
if (DI::mode()->isMobile()) {
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
if ($this->mode->isMobile()) {
$itemspage_network = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'itemspage_mobile_network',
$this->config->get('system', 'itemspage_network_mobile'));
} else {
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
$itemspage_network = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'itemspage_network',
$this->config->get('system', 'itemspage_network'));
}
$condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR
(`gravity` = ? AND `vid` = ? AND `origin`
AND EXISTS(SELECT `uri-id` FROM `post` WHERE `uri-id` = `post-user-view`.`thr-parent-id` AND `gravity` = ? AND `network` IN (?, ?))))",
Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB, Protocol::DFRN]);
Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB, Protocol::DFRN]);
$condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
'visible' => true, 'deleted' => false]);
$condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
'visible' => true, 'deleted' => false]);
$pager = new Pager(DI::l10n(), $args->getQueryString(), $itemspage_network);
$pager = new Pager($this->l10n, $this->args->getQueryString(), $itemspage_network);
$params = ['limit' => [$pager->getStart(), $pager->getItemsPerPage()], 'order' => ['received' => true]];
$items_stmt = Post::select(['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'received'], $condition, $params);
@ -187,29 +218,29 @@ class Status extends BaseProfile
// Set a time stamp for this page. We will make use of it when we
// search for new items (update routine)
$last_updated_array[$last_updated_key] = time();
DI::session()->set('last_updated', $last_updated_array);
$this->session->set('last_updated', $last_updated_array);
if ($is_owner && !DI::config()->get('theme', 'hide_eventlist')) {
if ($is_owner && !$this->config->get('theme', 'hide_eventlist')) {
$o .= ProfileModel::getBirthdays();
$o .= ProfileModel::getEventsReminderHTML();
}
if ($is_owner) {
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => $this->session->getLocalUserId()]);
if ($unseen) {
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => $this->session->getLocalUserId()]);
}
}
$items = Post::toArray($items_stmt);
if ($pager->getStart() == 0 && !empty($profile['uid'])) {
$pcid = Contact::getPublicIdByUserId($profile['uid']);
$pcid = Contact::getPublicIdByUserId($profile['uid']);
$pinned = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED);
$items = array_merge($items, $pinned);
$items = array_merge($items, $pinned);
}
$o .= DI::conversation()->create($items, 'profile', false, false, 'pinned_received', $profile['uid']);
$o .= $this->conversation->create($items, 'profile', false, false, 'pinned_received', $profile['uid']);
$o .= $pager->renderMinimal(count($items));

View file

@ -21,44 +21,71 @@
namespace Friendica\Module\Settings;
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
use Friendica\Navigation\SystemMessages;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
/**
* Module to update user settings
*/
class Display extends BaseSettings
{
/** @var IManageConfigValues */
private $config;
/** @var IManagePersonalConfigValues */
private $pConfig;
/** @var App */
private $app;
/** @var SystemMessages */
private $systemMessages;
public function __construct(SystemMessages $systemMessages, App $app, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config;
$this->pConfig = $pConfig;
$this->app = $app;
$this->systemMessages = $systemMessages;
}
protected function post(array $request = [])
{
if (!DI::app()->isLoggedIn()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
$uid = $this->session->getLocalUserId();
if (!$uid) {
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
}
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
$user = User::getById(DI::userSession()->getLocalUserId());
$user = User::getById($uid);
$theme = !empty($_POST['theme']) ? trim($_POST['theme']) : $user['theme'];
$mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : '';
$enable_smile = !empty($_POST['enable_smile']) ? intval($_POST['enable_smile']) : 0;
$first_day_of_week = !empty($_POST['first_day_of_week']) ? intval($_POST['first_day_of_week']) : 0;
$infinite_scroll = !empty($_POST['infinite_scroll']) ? intval($_POST['infinite_scroll']) : 0;
$no_auto_update = !empty($_POST['no_auto_update']) ? intval($_POST['no_auto_update']) : 0;
$enable_smart_threading = !empty($_POST['enable_smart_threading']) ? intval($_POST['enable_smart_threading']) : 0;
$enable_dislike = !empty($_POST['enable_dislike']) ? intval($_POST['enable_dislike']) : 0;
$display_resharer = !empty($_POST['display_resharer']) ? intval($_POST['display_resharer']) : 0;
$stay_local = !empty($_POST['stay_local']) ? intval($_POST['stay_local']) : 0;
$preview_mode = !empty($_POST['preview_mode']) ? intval($_POST['preview_mode']) : 0;
$browser_update = !empty($_POST['browser_update']) ? intval($_POST['browser_update']) : 0;
$theme = !empty($request['theme']) ? trim($request['theme']) : $user['theme'];
$mobile_theme = !empty($request['mobile_theme']) ? trim($request['mobile_theme']) : '';
$enable_smile = !empty($request['enable_smile']) ? intval($request['enable_smile']) : 0;
$first_day_of_week = !empty($request['first_day_of_week']) ? intval($request['first_day_of_week']) : 0;
$calendar_default_view = !empty($request['calendar_default_view']) ? trim($request['calendar_default_view']) : 'month';
$infinite_scroll = !empty($request['infinite_scroll']) ? intval($request['infinite_scroll']) : 0;
$no_auto_update = !empty($request['no_auto_update']) ? intval($request['no_auto_update']) : 0;
$enable_smart_threading = !empty($request['enable_smart_threading']) ? intval($request['enable_smart_threading']) : 0;
$enable_dislike = !empty($request['enable_dislike']) ? intval($request['enable_dislike']) : 0;
$display_resharer = !empty($request['display_resharer']) ? intval($request['display_resharer']) : 0;
$stay_local = !empty($request['stay_local']) ? intval($request['stay_local']) : 0;
$preview_mode = !empty($request['preview_mode']) ? intval($request['preview_mode']) : 0;
$browser_update = !empty($request['browser_update']) ? intval($request['browser_update']) : 0;
if ($browser_update != -1) {
$browser_update = $browser_update * 1000;
if ($browser_update < 10000) {
@ -66,89 +93,92 @@ class Display extends BaseSettings
}
}
$itemspage_network = !empty($_POST['itemspage_network']) ?
intval($_POST['itemspage_network']) :
DI::config()->get('system', 'itemspage_network');
$itemspage_network = !empty($request['itemspage_network']) ?
intval($request['itemspage_network']) :
$this->config->get('system', 'itemspage_network');
if ($itemspage_network > 100) {
$itemspage_network = 100;
}
$itemspage_mobile_network = !empty($_POST['itemspage_mobile_network']) ?
intval($_POST['itemspage_mobile_network']) :
DI::config()->get('system', 'itemspage_network_mobile');
$itemspage_mobile_network = !empty($request['itemspage_mobile_network']) ?
intval($request['itemspage_mobile_network']) :
$this->config->get('system', 'itemspage_network_mobile');
if ($itemspage_mobile_network > 100) {
$itemspage_mobile_network = 100;
}
if ($mobile_theme !== '') {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'mobile_theme', $mobile_theme);
$this->pConfig->set($uid, 'system', 'mobile_theme', $mobile_theme);
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network' , $itemspage_network);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'update_interval' , $browser_update);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update' , $no_auto_update);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smilies' , !$enable_smile);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll' , $infinite_scroll);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading' , !$enable_smart_threading);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike' , !$enable_dislike);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_resharer' , $display_resharer);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'stay_local' , $stay_local);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week' , $first_day_of_week);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'preview_mode' , $preview_mode);
$this->pConfig->set($uid, 'system', 'itemspage_network' , $itemspage_network);
$this->pConfig->set($uid, 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
$this->pConfig->set($uid, 'system', 'update_interval' , $browser_update);
$this->pConfig->set($uid, 'system', 'no_auto_update' , $no_auto_update);
$this->pConfig->set($uid, 'system', 'no_smilies' , !$enable_smile);
$this->pConfig->set($uid, 'system', 'infinite_scroll' , $infinite_scroll);
$this->pConfig->set($uid, 'system', 'no_smart_threading' , !$enable_smart_threading);
$this->pConfig->set($uid, 'system', 'hide_dislike' , !$enable_dislike);
$this->pConfig->set($uid, 'system', 'display_resharer' , $display_resharer);
$this->pConfig->set($uid, 'system', 'stay_local' , $stay_local);
$this->pConfig->set($uid, 'system', 'preview_mode' , $preview_mode);
$this->pConfig->set($uid, 'calendar', 'first_day_of_week' , $first_day_of_week);
$this->pConfig->set($uid, 'calendar', 'default_view' , $calendar_default_view);
if (in_array($theme, Theme::getAllowedList())) {
if ($theme == $user['theme']) {
// call theme_post only if theme has not been changed
if (($themeconfigfile = Theme::getConfigFile($theme)) !== null) {
if ($themeconfigfile = Theme::getConfigFile($theme)) {
require_once $themeconfigfile;
theme_post(DI::app());
theme_post($this->app);
}
} else {
DBA::update('user', ['theme' => $theme], ['uid' => DI::userSession()->getLocalUserId()]);
User::update(['theme' => $theme], $uid);
}
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
$this->systemMessages->addNotice($this->t('The theme you chose isn\'t available.'));
}
Hook::callAll('display_settings_post', $_POST);
Hook::callAll('display_settings_post', $request);
DI::baseUrl()->redirect('settings/display');
$this->baseUrl->redirect('settings/display');
}
protected function content(array $request = []): string
{
parent::content();
if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
$uid = $this->session->getLocalUserId();
if (!$uid) {
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
}
$default_theme = DI::config()->get('system', 'theme');
$default_theme = $this->config->get('system', 'theme');
if (!$default_theme) {
$default_theme = 'default';
}
$default_mobile_theme = DI::config()->get('system', 'mobile-theme');
$default_mobile_theme = $this->config->get('system', 'mobile-theme');
if (!$default_mobile_theme) {
$default_mobile_theme = 'none';
}
$user = User::getById(DI::userSession()->getLocalUserId());
$user = User::getById($uid);
$allowed_themes = Theme::getAllowedList();
$themes = [];
$mobile_themes = ["---" => DI::l10n()->t('No special theme for mobile devices')];
$mobile_themes = ['---' => $this->t('No special theme for mobile devices')];
foreach ($allowed_themes as $theme) {
$is_experimental = file_exists('view/theme/' . $theme . '/experimental');
$is_unsupported = file_exists('view/theme/' . $theme . '/unsupported');
$is_mobile = file_exists('view/theme/' . $theme . '/mobile');
if (!$is_experimental || (DI::config()->get('experimentals', 'exp_themes') || is_null(DI::config()->get('experimentals', 'exp_themes')))) {
if (!$is_experimental || $this->config->get('experimental', 'exp_themes')) {
$theme_name = ucfirst($theme);
if ($is_unsupported) {
$theme_name = DI::l10n()->t('%s - (Unsupported)', $theme_name);
$theme_name = $this->t('%s - (Unsupported)', $theme_name);
} elseif ($is_experimental) {
$theme_name = DI::l10n()->t('%s - (Experimental)', $theme_name);
$theme_name = $this->t('%s - (Experimental)', $theme_name);
}
if ($is_mobile) {
@ -160,84 +190,92 @@ class Display extends BaseSettings
}
$theme_selected = $user['theme'] ?: $default_theme;
$mobile_theme_selected = DI::session()->get('mobile-theme', $default_mobile_theme);
$mobile_theme_selected = $this->session->get('mobile-theme', $default_mobile_theme);
$itemspage_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network'));
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : DI::config()->get('system', 'itemspage_network'));
$itemspage_mobile_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network'));
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : DI::config()->get('system', 'itemspage_network_mobile'));
$itemspage_network = intval($this->pConfig->get($uid, 'system', 'itemspage_network'));
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : $this->config->get('system', 'itemspage_network'));
$itemspage_mobile_network = intval($this->pConfig->get($uid, 'system', 'itemspage_mobile_network'));
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : $this->config->get('system', 'itemspage_network_mobile'));
$browser_update = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'update_interval'));
if (intval($browser_update) != -1) {
$browser_update = intval($this->pConfig->get($uid, 'system', 'update_interval'));
if ($browser_update != -1) {
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
}
$no_auto_update = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update', 0);
$enable_smile = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smilies', 0);
$infinite_scroll = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll', 0);
$enable_smart_threading = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading', 0);
$enable_dislike = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike', 0);
$display_resharer = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_resharer', 0);
$stay_local = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'stay_local', 0);
$preview_mode = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
$no_auto_update = $this->pConfig->get($uid, 'system', 'no_auto_update', 0);
$enable_smile = !$this->pConfig->get($uid, 'system', 'no_smilies', 0);
$infinite_scroll = $this->pConfig->get($uid, 'system', 'infinite_scroll', 0);
$enable_smart_threading = !$this->pConfig->get($uid, 'system', 'no_smart_threading', 0);
$enable_dislike = !$this->pConfig->get($uid, 'system', 'hide_dislike', 0);
$display_resharer = $this->pConfig->get($uid, 'system', 'display_resharer', 0);
$stay_local = $this->pConfig->get($uid, 'system', 'stay_local', 0);
$first_day_of_week = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
$weekdays = [
0 => DI::l10n()->t("Sunday"),
1 => DI::l10n()->t("Monday"),
2 => DI::l10n()->t("Tuesday"),
3 => DI::l10n()->t("Wednesday"),
4 => DI::l10n()->t("Thursday"),
5 => DI::l10n()->t("Friday"),
6 => DI::l10n()->t("Saturday")
$preview_mode = $this->pConfig->get($uid, 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
$preview_modes = [
BBCode::PREVIEW_NONE => $this->t('No preview'),
BBCode::PREVIEW_NO_IMAGE => $this->t('No image'),
BBCode::PREVIEW_SMALL => $this->t('Small Image'),
BBCode::PREVIEW_LARGE => $this->t('Large Image'),
];
$preview_modes = [
BBCode::PREVIEW_NONE => DI::l10n()->t('No preview'),
BBCode::PREVIEW_NO_IMAGE => DI::l10n()->t('No image'),
BBCode::PREVIEW_SMALL => DI::l10n()->t('Small Image'),
BBCode::PREVIEW_LARGE => DI::l10n()->t('Large Image'),
$first_day_of_week = $this->pConfig->get($uid, 'system', 'first_day_of_week', 0);
$weekdays = [
0 => $this->t('Sunday'),
1 => $this->t('Monday'),
2 => $this->t('Tuesday'),
3 => $this->t('Wednesday'),
4 => $this->t('Thursday'),
5 => $this->t('Friday'),
6 => $this->t('Saturday')
];
$calendar_default_view = $this->pConfig->get($uid, 'calendar', 'default_view', 'month');
$calendarViews = [
'month' => $this->t('month'),
'agendaWeek' => $this->t('week'),
'agendaDay' => $this->t('day'),
'listMonth' => $this->t('list')
];
$theme_config = '';
if ($themeconfigfile = Theme::getConfigFile($theme_selected)) {
require_once $themeconfigfile;
$theme_config = theme_content(DI::app());
$theme_config = theme_content($this->app);
}
$tpl = Renderer::getMarkupTemplate('settings/display.tpl');
$o = Renderer::replaceMacros($tpl, [
'$ptitle' => DI::l10n()->t('Display Settings'),
'$submit' => DI::l10n()->t('Save Settings'),
'$d_tset' => DI::l10n()->t('General Theme Settings'),
'$d_ctset' => DI::l10n()->t('Custom Theme Settings'),
'$d_cset' => DI::l10n()->t('Content Settings'),
'$stitle' => DI::l10n()->t('Theme settings'),
'$calendar_title' => DI::l10n()->t('Calendar'),
return Renderer::replaceMacros($tpl, [
'$ptitle' => $this->t('Display Settings'),
'$submit' => $this->t('Save Settings'),
'$d_tset' => $this->t('General Theme Settings'),
'$d_ctset' => $this->t('Custom Theme Settings'),
'$d_cset' => $this->t('Content Settings'),
'$stitle' => $this->t('Theme settings'),
'$calendar_title' => $this->t('Calendar'),
'$form_security_token' => self::getFormSecurityToken('settings_display'),
'$baseurl' => DI::baseUrl()->get(true),
'$uid' => DI::userSession()->getLocalUserId(),
'$baseurl' => $this->baseUrl->get(true),
'$uid' => $uid,
'$theme' => ['theme', DI::l10n()->t('Display Theme:'), $theme_selected, '', $themes, true],
'$mobile_theme' => ['mobile_theme', DI::l10n()->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
'$theme' => ['theme', $this->t('Display Theme:'), $theme_selected, '', $themes, true],
'$mobile_theme' => ['mobile_theme', $this->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
'$theme_config' => $theme_config,
'$itemspage_network' => ['itemspage_network' , DI::l10n()->t('Number of items to display per page:'), $itemspage_network, DI::l10n()->t('Maximum of 100 items')],
'$itemspage_mobile_network' => ['itemspage_mobile_network', DI::l10n()->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, DI::l10n()->t('Maximum of 100 items')],
'$ajaxint' => ['browser_update' , DI::l10n()->t('Update browser every xx seconds'), $browser_update, DI::l10n()->t('Minimum of 10 seconds. Enter -1 to disable it.')],
'$no_auto_update' => ['no_auto_update' , DI::l10n()->t('Automatic updates only at the top of the post stream pages'), $no_auto_update, DI::l10n()->t('Auto update may add new posts at the top of the post stream pages, which can affect the scroll position and perturb normal reading if it happens anywhere else the top of the page.')],
'$enable_smile' => ['enable_smile' , DI::l10n()->t('Display emoticons'), $enable_smile, DI::l10n()->t('When enabled, emoticons are replaced with matching symbols.')],
'$infinite_scroll' => ['infinite_scroll' , DI::l10n()->t('Infinite scroll'), $infinite_scroll, DI::l10n()->t('Automatic fetch new items when reaching the page end.')],
'$enable_smart_threading' => ['enable_smart_threading' , DI::l10n()->t('Enable Smart Threading'), $enable_smart_threading, DI::l10n()->t('Enable the automatic suppression of extraneous thread indentation.')],
'$enable_dislike' => ['enable_dislike' , DI::l10n()->t('Display the Dislike feature'), $enable_dislike, DI::l10n()->t('Display the Dislike button and dislike reactions on posts and comments.')],
'$display_resharer' => ['display_resharer' , DI::l10n()->t('Display the resharer'), $display_resharer, DI::l10n()->t('Display the first resharer as icon and text on a reshared item.')],
'$stay_local' => ['stay_local' , DI::l10n()->t('Stay local'), $stay_local, DI::l10n()->t("Don't go to a remote system when following a contact link.")],
'$preview_mode' => ['preview_mode' , DI::l10n()->t('Link preview mode'), $preview_mode, 'Appearance of the link preview that is added to each post with a link.', $preview_modes, false],
'$itemspage_network' => ['itemspage_network' , $this->t('Number of items to display per page:'), $itemspage_network, $this->t('Maximum of 100 items')],
'$itemspage_mobile_network' => ['itemspage_mobile_network', $this->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, $this->t('Maximum of 100 items')],
'$ajaxint' => ['browser_update' , $this->t('Update browser every xx seconds'), $browser_update, $this->t('Minimum of 10 seconds. Enter -1 to disable it.')],
'$no_auto_update' => ['no_auto_update' , $this->t('Automatic updates only at the top of the post stream pages'), $no_auto_update, $this->t('Auto update may add new posts at the top of the post stream pages, which can affect the scroll position and perturb normal reading if it happens anywhere else the top of the page.')],
'$enable_smile' => ['enable_smile' , $this->t('Display emoticons'), $enable_smile, $this->t('When enabled, emoticons are replaced with matching symbols.')],
'$infinite_scroll' => ['infinite_scroll' , $this->t('Infinite scroll'), $infinite_scroll, $this->t('Automatic fetch new items when reaching the page end.')],
'$enable_smart_threading' => ['enable_smart_threading' , $this->t('Enable Smart Threading'), $enable_smart_threading, $this->t('Enable the automatic suppression of extraneous thread indentation.')],
'$enable_dislike' => ['enable_dislike' , $this->t('Display the Dislike feature'), $enable_dislike, $this->t('Display the Dislike button and dislike reactions on posts and comments.')],
'$display_resharer' => ['display_resharer' , $this->t('Display the resharer'), $display_resharer, $this->t('Display the first resharer as icon and text on a reshared item.')],
'$stay_local' => ['stay_local' , $this->t('Stay local'), $stay_local, $this->t("Don't go to a remote system when following a contact link.")],
'$preview_mode' => ['preview_mode' , $this->t('Link preview mode'), $preview_mode, $this->t('Appearance of the link preview that is added to each post with a link.'), $preview_modes, false],
'$first_day_of_week' => ['first_day_of_week', DI::l10n()->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
'$first_day_of_week' => ['first_day_of_week' , $this->t('Beginning of week:') , $first_day_of_week , '', $weekdays , false],
'$calendar_default_view' => ['calendar_default_view', $this->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false],
]);
return $o;
}
}

View file

@ -262,7 +262,7 @@ class Index extends BaseSettings
<p>Reorder by dragging the field title.</p>
<p>Empty the label field to remove a custom field.</p>
<p>Non-public fields can only be seen by the selected Friendica contacts or the Friendica contacts in the selected groups.</p>",
'profile/' . $profile['nickname']
'profile/' . $profile['nickname'] . '/profile'
),
'$custom_fields' => $custom_fields,
]);

View file

@ -83,13 +83,15 @@ class Tos extends BaseModule
$tpl = Renderer::getMarkupTemplate('tos.tpl');
if ($this->config->get('system', 'tosdisplay')) {
$lines = $this->config->get('system', 'tosrules');
if (!empty($lines)) {
$rules = "[list=1]";
$lines = trim($this->config->get('system', 'tosrules') ?: '');
if ($lines) {
$rules = "[ol]";
foreach (explode("\n", $lines) as $line) {
$rules .= "\n[*]" . $line;
if (trim($line)) {
$rules .= "\n[*]" . trim($line);
}
}
$rules .= "\n[/list]\n";
$rules .= "\n[/ol]\n";
} else {
$rules = '';
}

View file

@ -59,9 +59,9 @@ class Display extends DisplayModule
$parentUriId = $item['parent-uri-id'];
if (empty($force)) {
$browserUpdate = $this->pConfig->get($profileUid, 'system', 'update_interval');
if (!empty($browserUpdate)) {
$updateDate = date(DateTimeFormat::MYSQL, time() - (intval($browserUpdate) / 500));
$browserUpdate = intval($this->pConfig->get($profileUid, 'system', 'update_interval') ?? 40000);
if ($browserUpdate >= 1000) {
$updateDate = date(DateTimeFormat::MYSQL, time() - ($browserUpdate * 2 / 1000));
if (!Post::exists([
"`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?",
$parentUriId, 0,

View file

@ -139,8 +139,17 @@ class Probe
foreach ([Protocol::DIASPORA, Protocol::OSTATUS] as $network) {
if (!empty($data['networks'][$network])) {
$data['networks'][$network]['subscribe'] = $newdata['subscribe'] ?? '';
$data['networks'][$network]['baseurl'] = $newdata['baseurl'] ?? '';
$data['networks'][$network]['gsid'] = $newdata['gsid'] ?? 0;
if (empty($data['networks'][$network]['baseurl'])) {
$data['networks'][$network]['baseurl'] = $newdata['baseurl'] ?? '';
} else {
$newdata['baseurl'] = $data['networks'][$network]['baseurl'];
}
if (!empty($newdata['baseurl'])) {
$newdata['gsid'] = $data['networks'][$network]['gsid'] = GServer::getID($newdata['baseurl']);
} else {
$newdata['gsid'] = $data['networks'][$network]['gsid'] = null;
}
$newdata['networks'][$network] = self::rearrangeData($data['networks'][$network]);
unset($newdata['networks'][$network]['networks']);
}

View file

@ -37,14 +37,12 @@ class FollowRequest extends Account
*
* @param BaseURL $baseUrl
* @param int $introduction_id Introduction record id
* @param array $publicContact Full contact table record with uid = 0
* @param array $apcontact Optional full apcontact table record
* @param array $userContact Optional full contact table record with uid != 0
* @param array $account entry of "account-user-view"
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(BaseURL $baseUrl, int $introduction_id, array $publicContact, array $apcontact = [], array $userContact = [])
public function __construct(BaseURL $baseUrl, int $introduction_id, array $account)
{
parent::__construct($baseUrl, $publicContact, new Fields(), $apcontact, $userContact);
parent::__construct($baseUrl, $account, new Fields());
$this->id = $introduction_id;
}

View file

@ -114,7 +114,7 @@ class Status extends BaseDataTransferObject
$visibility = ['public', 'private', 'unlisted'];
$this->visibility = $visibility[$item['private']];
$languages = json_decode($item['language'], true);
$languages = json_decode($item['language'] ?? '', true);
if (is_array($languages)) {
reset($languages);
$this->language = key($languages);

View file

@ -66,6 +66,7 @@ class Image
$this->type = $type;
if ($this->isImagick() && (empty($data) || $this->loadData($data))) {
$this->valid = !empty($data);
return;
} else {
// Failed to load with Imagick, fallback
@ -158,12 +159,11 @@ class Image
$this->image->setCompressionQuality($quality);
}
// The 'width' and 'height' properties are only used by non-Imagick routines.
$this->width = $this->image->getImageWidth();
$this->height = $this->image->getImageHeight();
$this->valid = true;
$this->valid = !empty($this->image);
return true;
return $this->valid;
}
$this->valid = false;
@ -210,9 +210,6 @@ class Image
return false;
}
if ($this->isImagick()) {
return $this->image->getImageWidth();
}
return $this->width;
}
@ -225,9 +222,6 @@ class Image
return false;
}
if ($this->isImagick()) {
return $this->image->getImageHeight();
}
return $this->height;
}
@ -353,6 +347,9 @@ class Image
do {
$this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
} while ($this->image->nextImage());
$this->width = $this->image->getImageWidth();
$this->height = $this->image->getImageHeight();
return;
}
@ -576,7 +573,6 @@ class Image
}
} while ($this->image->nextImage());
// These may not be necessary anymore
$this->width = $this->image->getImageWidth();
$this->height = $this->image->getImageHeight();
} else {
@ -659,7 +655,7 @@ class Image
if ($this->image) {
imagedestroy($this->image);
}
$this->image = $dest;
$this->image = $dest;
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
@ -734,7 +730,7 @@ class Image
public function getBlurHash(): string
{
$image = New Image($this->asString());
if (empty($image)) {
if (empty($image) || !$this->isValid()) {
return '';
}
@ -809,12 +805,14 @@ class Image
if ($this->isImagick()) {
$this->image->drawImage($draw);
$this->width = $this->image->getImageWidth();
$this->height = $this->image->getImageHeight();
} else {
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
}
$this->valid = true;
$this->valid = !empty($this->image);
$this->scaleUp(min($width, $height));
}

View file

@ -1477,28 +1477,28 @@ class Transmitter
*/
private static function removePictures(string $body): string
{
// Simplify image codes
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
$body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $body);
return BBCode::performWithEscapedTags($body, ['code', 'noparse', 'nobb', 'pre'], function ($text) {
// Simplify image codes
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $text);
$text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $text);
// Now remove local links
$body = preg_replace_callback(
'/\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]/Usi',
function ($match) {
// We remove the link when it is a link to a local photo page
if (Photo::isLocalPage($match[1])) {
return '';
}
// otherwise we just return the link
return '[url]' . $match[1] . '[/url]';
},
$body
);
// Now remove local links
$text = preg_replace_callback(
'/\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]/Usi',
function ($match) {
// We remove the link when it is a link to a local photo page
if (Photo::isLocalPage($match[1])) {
return '';
}
// otherwise we just return the link
return '[url]' . $match[1] . '[/url]';
},
$text
);
// Remove all pictures
$body = preg_replace("/\[img\]([^\[\]]*)\[\/img\]/Usi", '', $body);
return $body;
// Remove all pictures
return preg_replace("/\[img\]([^\[\]]*)\[\/img\]/Usi", '', $text);
});
}
/**

View file

@ -499,7 +499,7 @@ class Diaspora
}
if (!($fields = self::validPosting($msg))) {
Logger::warning('Invalid posting', ['msg' => $msg]);
Logger::notice('Invalid posting', ['msg' => $msg]);
return false;
}

View file

@ -140,7 +140,7 @@ class JsonLD
* @return array Compacted JSON array
* @throws Exception
*/
public static function compact($json, bool $logfailed = true)
public static function compact($json, bool $logfailed = true): array
{
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
@ -177,6 +177,12 @@ class JsonLD
if (!in_array('https://w3id.org/security/v1', $json['@context'])) {
$json['@context'][] = 'https://w3id.org/security/v1';
}
// Issue 12419: Workaround for GoToSocial
$pos = array_search('http://joinmastodon.org/ns', $json['@context']);
if (is_int($pos)) {
$json['@context'][$pos] = ['toot' => 'http://joinmastodon.org/ns#'];
}
}
// Bookwyrm transmits "id" fields with "null", which isn't allowed.
@ -203,6 +209,11 @@ class JsonLD
$json = json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
if ($json === false) {
Logger::notice('JSON encode->decode failed', ['orig_json' => $orig_json, 'compacted' => $compacted]);
$json = [];
}
return $json;
}

View file

@ -380,29 +380,47 @@ class Strings
* Returns the regular expression string to match URLs in a given text
*
* @return string
* @see https://daringfireball.net/2010/07/improved_regex_for_matching_urls
*/
public static function autoLinkRegEx(): string
{
return '@
(?<![=\'\]"/]) # Not preceded by [, =, \', ], ", /
(?<![=\'\]"/]) # Not preceded by [, =, \', ], ", /
\b
( # Capture 1: entire matched URL
https?:// # http or https protocol
( # Capture 1: entire matched URL
' . self::linkRegEx() . '
)@xiu';
}
/**
* Returns the regular expression string to match only an HTTP URL
*
* @return string
*/
public static function onlyLinkRegEx(): string
{
return '@^' . self::linkRegEx() . '$@xiu';
}
/**
* @return string
* @see https://daringfireball.net/2010/07/improved_regex_for_matching_urls
*/
private static function linkRegEx(): string
{
return 'https?:// # http or https protocol
(?:
[^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’.] # Domain can\'t start with a .
[^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’]+ # Domain can\'t end with a .
[^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’.] # Domain can\'t start with a .
[^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’]+ # Domain can\'t end with a .
\.
[^/\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’]+/? # Followed by a slash
)
(?: # One or more:
[^\s\xA0()<>]+ # Run of non-space, non-()<>
| # or
\(([^\s\xA0()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
| # or
[^\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars
)*
)@xiu';
(?: # One or more:
[^\s\xA0()<>]+ # Run of non-space, non-()<>
| # or
\(([^\s\xA0()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
| # or
[^\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars
)*';
}
/**

View file

@ -30,6 +30,7 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Group;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\PushSubscriber;
@ -99,7 +100,7 @@ class Notifier
$uid = $target_id;
$condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'batch'], $condition);
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
} else {
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
if (!DBA::isResult($post)) {
@ -425,7 +426,7 @@ class Notifier
if (!empty($networks)) {
$condition['network'] = $networks;
}
$delivery_contacts_stmt = DBA::select('contact', ['id', 'addr', 'url', 'network', 'protocol', 'batch'], $condition);
$delivery_contacts_stmt = DBA::select('contact', ['id', 'addr', 'url', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
}
$conversants = [];
@ -437,7 +438,7 @@ class Notifier
if ($diaspora_delivery && !$unlisted) {
$batch_delivery = true;
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'id', 'url', 'name'],
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'baseurl', 'gsid', 'id', 'url', 'name'],
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
['group_by' => ['batch', 'network', 'protocol']]);
@ -449,7 +450,7 @@ class Notifier
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
$contacts = DBA::selectToArray('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol'], $condition);
$contacts = DBA::selectToArray('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol', 'baseurl', 'gsid'], $condition);
$conversants = array_merge($contacts, $participants);
@ -563,6 +564,11 @@ class Notifier
continue;
}
if (!GServer::reachable($contact)) {
Logger::info('Server is not reachable', ['id' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact]);
continue;
}
Logger::info('Delivery', ['batch' => $in_batch, 'target' => $post_uriid, 'uid' => $sender_uid, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
// Ensure that posts with our own protocol arrives before Diaspora posts arrive.