Merge remote-tracking branch 'upstream/2022.12-rc' into diaspora-reshare

This commit is contained in:
Michael 2022-12-17 12:27:35 +00:00
commit 8397ccf37c
37 changed files with 9253 additions and 8578 deletions

View file

@ -50,7 +50,7 @@ class Features extends BaseAdmin
DI::config()->set('feature', $feature, $val);
if (!empty($_POST[$featurelock])) {
DI::config()->set('feature_lock', $feature, $val);
DI::config()->set('feature_lock', $feature, 1);
} else {
DI::config()->delete('feature_lock', $feature);
}

View file

@ -475,7 +475,7 @@ class Site extends BaseAdmin
'$maximagesize' => ['maximagesize', DI::l10n()->t('Maximum image size'), DI::config()->get('system', 'maximagesize'), DI::l10n()->t('Maximum size in bytes of uploaded images. Default is 0, which means no limits. You can put k, m, or g behind the desired value for KiB, MiB, GiB, respectively.
The value of <code>upload_max_filesize</code> in your <code>PHP.ini</code> needs be set to at least the desired limit.
Currently <code>upload_max_filesize</code> is set to %s (%sB)', Strings::getBytesFromShorthand(ini_get('upload_max_filesize')), ini_get('upload_max_filesize')),
Currently <code>upload_max_filesize</code> is set to %s (%s byte)', Strings::formatBytes(Strings::getBytesFromShorthand(ini_get('upload_max_filesize'))), Strings::getBytesFromShorthand(ini_get('upload_max_filesize'))),
'', 'pattern="\d+(?:\s*[kmg])?"'],
'$maximagelength' => ['maximagelength', DI::l10n()->t('Maximum image length'), DI::config()->get('system', 'max_image_length'), DI::l10n()->t('Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.')],
'$jpegimagequality' => ['jpegimagequality', DI::l10n()->t('JPEG image quality'), DI::config()->get('system', 'jpeg_quality'), DI::l10n()->t('Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.')],

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter\Followers;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Module\Api\Twitter\ContactEndpoint;
use Friendica\Module\BaseApi;
@ -47,35 +48,64 @@ class Ids extends ContactEndpoint
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
$min_id = $this->getRequestValue($request, 'min_id', 0, 0);
$params = ['order' => ['relation-cid' => true], 'limit' => $count];
if ($cid == Contact::getPublicIdByUserId($uid)) {
$params = ['order' => ['pid' => true], 'limit' => $count];
$condition = ['cid' => $cid, 'follows' => true];
$condition = ['uid' => $uid, 'self' => false, 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
$total_count = (int)DBA::count('contact', $condition);
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $min_id]);
$params['order'] = ['pid'];
}
$ids = [];
foreach (Contact::selectAccountToArray(['pid'], $condition, $params) as $follower) {
self::setBoundaries($follower['pid']);
$ids[] = $follower['pid'];
}
} else {
$params = ['order' => ['relation-cid' => true], 'limit' => $count];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $max_id]);
$condition = ['cid' => $cid, 'follows' => true];
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]);
$params['order'] = ['relation-cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['relation-cid']);
$ids[] = $follower['relation-cid'];
}
DBA::close($followers);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]);
$params['order'] = ['relation-cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['relation-cid']);
$ids[] = $follower['relation-cid'];
}
DBA::close($followers);
if (!empty($min_id)) {
$ids = array_reverse($ids);
}

View file

@ -21,8 +21,8 @@
namespace Friendica\Module\Api\Twitter\Followers;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Module\Api\Twitter\ContactEndpoint;
use Friendica\Module\BaseApi;
@ -48,42 +48,71 @@ class Lists extends ContactEndpoint
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
$min_id = $this->getRequestValue($request, 'min_id', 0, 0);
$params = ['order' => ['relation-cid' => true], 'limit' => $count];
if ($cid == Contact::getPublicIdByUserId($uid)) {
$params = ['order' => ['pid' => true], 'limit' => $count];
$condition = ['cid' => $cid, 'follows' => true];
$condition = ['uid' => $uid, 'self' => false, 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
$total_count = (int)DBA::count('contact', $condition);
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $min_id]);
$params['order'] = ['pid'];
}
$ids = [];
foreach (Contact::selectAccountToArray(['pid'], $condition, $params) as $follower) {
self::setBoundaries($follower['pid']);
$ids[] = $follower['pid'];
}
} else {
$params = ['order' => ['relation-cid' => true], 'limit' => $count];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $max_id]);
$condition = ['cid' => $cid, 'follows' => true];
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]);
$params['order'] = ['relation-cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['relation-cid']);
$ids[] = $follower['relation-cid'];
}
DBA::close($followers);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]);
$params['order'] = ['relation-cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['relation-cid']);
$ids[] = $follower['relation-cid'];
}
DBA::close($followers);
if (!empty($min_id)) {
$ids = array_reverse($ids);
}
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
self::setLinkHeader();
$this->response->setHeader(self::getLinkHeader());
$this->response->exit('lists', ['lists' => $return]);
}

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter\Friends;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Module\Api\Twitter\ContactEndpoint;
use Friendica\Module\BaseApi;
@ -47,35 +48,64 @@ class Ids extends ContactEndpoint
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
$min_id = $this->getRequestValue($request, 'min_id', 0, 0);
$params = ['order' => ['cid' => true], 'limit' => $count];
if ($cid == Contact::getPublicIdByUserId($uid)) {
$params = ['order' => ['pid' => true], 'limit' => $count];
$condition = ['relation-cid' => $cid, 'follows' => true];
$condition = ['uid' => $uid, 'self' => false, 'pending' => false, 'rel' => [Contact::SHARING, Contact::FRIEND]];
$total_count = (int)DBA::count('contact', $condition);
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $min_id]);
$params['order'] = ['pid'];
}
$ids = [];
foreach (Contact::selectAccountToArray(['pid'], $condition, $params) as $follower) {
self::setBoundaries($follower['pid']);
$ids[] = $follower['pid'];
}
} else {
$params = ['order' => ['cid' => true], 'limit' => $count];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]);
$condition = ['relation-cid' => $cid, 'follows' => true];
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]);
$params['order'] = ['cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$ids[] = $follower['cid'];
}
DBA::close($followers);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]);
$params['order'] = ['cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$ids[] = $follower['cid'];
}
DBA::close($followers);
if (!empty($min_id)) {
$ids = array_reverse($ids);
}

View file

@ -21,8 +21,8 @@
namespace Friendica\Module\Api\Twitter\Friends;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Module\Api\Twitter\ContactEndpoint;
use Friendica\Module\BaseApi;
@ -48,42 +48,71 @@ class Lists extends ContactEndpoint
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
$min_id = $this->getRequestValue($request, 'min_id', 0, 0);
$params = ['order' => ['cid' => true], 'limit' => $count];
if ($cid == Contact::getPublicIdByUserId($uid)) {
$params = ['order' => ['pid' => true], 'limit' => $count];
$condition = ['relation-cid' => $cid, 'follows' => true];
$condition = ['uid' => $uid, 'self' => false, 'pending' => false, 'rel' => [Contact::SHARING, Contact::FRIEND]];
$total_count = (int)DBA::count('contact', $condition);
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`pid` > ?", $min_id]);
$params['order'] = ['pid'];
}
$ids = [];
foreach (Contact::selectAccountToArray(['pid'], $condition, $params) as $follower) {
self::setBoundaries($follower['pid']);
$ids[] = $follower['pid'];
}
} else {
$params = ['order' => ['cid' => true], 'limit' => $count];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]);
$condition = ['relation-cid' => $cid, 'follows' => true];
$total_count = (int)DBA::count('contact-relation', $condition);
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]);
$params['order'] = ['cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$ids[] = $follower['cid'];
}
DBA::close($followers);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]);
$params['order'] = ['cid'];
}
$ids = [];
$followers = DBA::select('contact-relation', ['cid'], $condition, $params);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$ids[] = $follower['cid'];
}
DBA::close($followers);
if (!empty($min_id)) {
$ids = array_reverse($ids);
}
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
self::setLinkHeader();
$this->response->setHeader(self::getLinkHeader());
$this->response->exit('lists', ['lists' => $return]);
}

View file

@ -21,7 +21,6 @@
namespace Friendica\Module\Api\Twitter\Friendships;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Module\Api\Twitter\ContactEndpoint;
use Friendica\Module\BaseApi;
@ -81,7 +80,7 @@ class Incoming extends ContactEndpoint
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
self::setLinkHeader();
$this->response->setHeader(self::getLinkHeader());
$this->response->exit('incoming', ['incoming' => $return]);
}

View file

@ -139,13 +139,13 @@ class BaseApi extends BaseModule
}
/**
* Set the "link" header with "next" and "prev" links
* @return void
* Get the "link" header with "next" and "prev" links
* @return string
*/
protected static function setLinkHeader()
protected static function getLinkHeader(): string
{
if (empty(self::$boundaries)) {
return;
return '';
}
$request = self::$request;
@ -164,7 +164,19 @@ class BaseApi extends BaseModule
$prev = $command . '?' . http_build_query($prev_request);
$next = $command . '?' . http_build_query($next_request);
header('Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"');
return 'Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"';
}
/**
* Set the "link" header with "next" and "prev" links
* @return void
*/
protected static function setLinkHeader()
{
$header = self::getLinkHeader();
if (!empty($header)) {
header($header);
}
}
/**

View file

@ -31,6 +31,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\Theme;
use Friendica\Model\Event;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Module\BaseProfile;
use Friendica\Module\Response;
@ -68,7 +69,7 @@ class Show extends BaseModule
throw new HTTPException\UnauthorizedException();
}
$owner = User::getOwnerDataByNick($nickname);
$owner = Profile::load($this->app, $nickname, false);
if (!$owner || $owner['account_expired'] || $owner['account_removed']) {
throw new HTTPException\NotFoundException($this->t('User not found.'));
}
@ -102,8 +103,9 @@ class Show extends BaseModule
Nav::setSelected($is_owner ? 'home' : 'calendar');
if (!$is_owner) {
$this->page['aside'] .= Widget\VCard::getHTML($owner);
if ($is_owner) {
// Removing the vCard added by Profile::load for owners
$this->page['aside'] = '';
}
$this->page['aside'] .= Widget\CalendarExport::getHTML($owner['uid']);

View file

@ -191,7 +191,7 @@ class Contact extends BaseModule
$rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel);
$groups_widget = Widget::groups($_SERVER['REQUEST_URI'], $group);
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $account_widget . $groups_widget . $networks_widget . $rel_widget;
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $rel_widget . $groups_widget . $networks_widget . $account_widget;
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [

View file

@ -116,8 +116,8 @@ class Ping extends BaseModule
$birthday_count = 0;
$today_birthday_count = 0;
if ($this->session->getLocalUserId()) {
// Suppress notification display for forum accounts
if ($this->session->getLocalUserId() && $this->session->get('page_flags', '') != User::PAGE_FLAGS_COMMUNITY) {
if ($this->pconfig->get($this->session->getLocalUserId(), 'system', 'detailed_notif')) {
$notifications = $this->notificationRepo->selectDetailedForUser($this->session->getLocalUserId());
} else {

View file

@ -142,7 +142,7 @@ class Subscribe extends \Friendica\BaseModule
$o .= '<p>' . $counter . '/' . $total . ': ' . $url;
$probed = Contact::getByURL($url);
if (in_array($probed['network'], Protocol::FEDERATED)) {
if (!empty($probed['network']) && in_array($probed['network'], Protocol::FEDERATED)) {
$result = Contact::createFromProbeForUser($this->session->getLocalUserId(), $probed['url']);
if ($result['success']) {
$o .= ' - ' . $this->t('success');

View file

@ -377,7 +377,7 @@ class Photo extends BaseModule
$url = Contact::getDefaultAvatar($contact ?: [], Proxy::SIZE_SMALL);
}
}
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext, $contact['blurhash'], $customsize, $customsize);
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext, $contact['blurhash'] ?? null, $customsize, $customsize);
case 'header':
$fields = ['uid', 'url', 'header', 'network', 'gsid'];
$contact = Contact::getById($id, $fields);