Merge remote-tracking branch 'upstream/develop' into logging

This commit is contained in:
Michael 2021-10-25 18:56:29 +00:00
commit 87673fd0c5
60 changed files with 4012 additions and 2911 deletions

View file

@ -31,6 +31,7 @@ use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
use Friendica\Util\Strings;
@ -84,11 +85,8 @@ class Objects extends BaseModule
$requester_id = Contact::getIdForURL($requester, $item['uid']);
if (!empty($requester_id)) {
$permissionSets = DI::permissionSet()->selectByContactId($requester_id, $item['uid']);
if (!empty($permissionSets)) {
$psid = array_merge($permissionSets->column('id'),
[DI::permissionSet()->selectPublicForUser($item['uid'])]);
$validated = in_array($item['psid'], $psid);
}
$psids = array_merge($permissionSets->column('id'), [PermissionSet::PUBLIC]);
$validated = in_array($item['psid'], $psids);
}
}
}

View file

@ -163,6 +163,7 @@ class Site extends BaseAdmin
$allow_users_remote_self = !empty($_POST['allow_users_remote_self']);
$explicit_content = !empty($_POST['explicit_content']);
$proxify_content = !empty($_POST['proxify_content']);
$cache_contact_avatar = !empty($_POST['cache_contact_avatar']);
$enable_multi_reg = !empty($_POST['enable_multi_reg']);
$enable_openid = !empty($_POST['enable_openid']);
@ -330,6 +331,7 @@ class Site extends BaseAdmin
DI::config()->set('system', 'allow_users_remote_self', $allow_users_remote_self);
DI::config()->set('system', 'explicit_content' , $explicit_content);
DI::config()->set('system', 'proxify_content' , $proxify_content);
DI::config()->set('system', 'cache_contact_avatar' , $cache_contact_avatar);
DI::config()->set('system', 'check_new_version_url' , $check_new_version_url);
DI::config()->set('system', 'block_extended_register', !$enable_multi_reg);
@ -554,6 +556,7 @@ class Site extends BaseAdmin
'$disable_embedded' => ['disable_embedded', DI::l10n()->t('Don\'t embed private images in posts'), DI::config()->get('system', 'disable_embedded'), DI::l10n()->t('Don\'t replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.')],
'$explicit_content' => ['explicit_content', DI::l10n()->t('Explicit Content'), DI::config()->get('system', 'explicit_content'), DI::l10n()->t('Set this to announce that your node is used mostly for explicit content that might not be suited for minors. This information will be published in the node information and might be used, e.g. by the global directory, to filter your node from listings of nodes to join. Additionally a note about this will be shown at the user registration page.')],
'$proxify_content' => ['proxify_content', DI::l10n()->t('Proxify external content'), DI::config()->get('system', 'proxify_content'), DI::l10n()->t('Route external content via the proxy functionality. This is used for example for some OEmbed accesses and in some other rare cases.')],
'$cache_contact_avatar' => ['cache_contact_avatar', DI::l10n()->t('Cache contact avatars'), DI::config()->get('system', 'cache_contact_avatar'), DI::l10n()->t('Locally store the avatar pictures of the contacts. This uses a lot of storage space but it increases the performance.')],
'$allow_users_remote_self'=> ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
'$enable_multi_reg' => ['enable_multi_reg', DI::l10n()->t('Enable multiple registrations'), !DI::config()->get('system', 'block_extended_register'), DI::l10n()->t('Enable users to register additional accounts for use as pages.')],
'$enable_openid' => ['enable_openid', DI::l10n()->t('Enable OpenID'), !DI::config()->get('system', 'no_openid'), DI::l10n()->t('Enable OpenID support for registration and logins.')],

View file

@ -28,7 +28,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
use Friendica\Security\PermissionSet\Depository\PermissionSet;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
/**
* API endpoint: /api/friendica/profile/show

View file

@ -68,16 +68,15 @@ class FriendSuggest extends BaseModule
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
$suggest = DI::fsuggest()->insert([
'uid' => local_user(),
'cid' => $cid,
'name' => $contact['name'],
'url' => $contact['url'],
'request' => $contact['request'],
'photo' => $contact['avatar'],
'note' => $note,
'created' => DateTimeFormat::utcNow()
]);
$suggest = DI::fsuggest()->save(DI::fsuggestFactory()->createNew(
local_user(),
$cid,
$contact['name'],
$contact['url'],
$contact['request'],
$contact['avatar'],
$note
));
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
@ -94,7 +93,7 @@ class FriendSuggest extends BaseModule
DI::baseUrl()->redirect();
}
$contacts = ContactModel::selectToArray(['id', 'name'], [
$suggestableContacts = ContactModel::selectToArray(['id', 'name'], [
'`uid` = ?
AND `id` != ?
AND `network` = ?
@ -111,8 +110,8 @@ class FriendSuggest extends BaseModule
$formattedContacts = [];
foreach ($contacts as $contact) {
$formattedContacts[$contact['id']] = $contact['name'];
foreach ($suggestableContacts as $suggestableContact) {
$formattedContacts[$suggestableContact['id']] = $suggestableContact['name'];
}
$tpl = Renderer::getMarkupTemplate('fsuggest.tpl');

View file

@ -36,6 +36,7 @@ use Friendica\Network\HTTPException;
use Friendica\Object\Image;
use Friendica\Util\Images;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use Friendica\Util\Proxy;
/**
@ -284,14 +285,26 @@ class Photo extends BaseModule
$url = $contact['avatar'];
} elseif (!empty($contact['avatar'])) {
$url = $contact['avatar'];
} elseif ($customsize <= Proxy::PIXEL_MICRO) {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
} elseif ($customsize <= Proxy::PIXEL_THUMB) {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
} else {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
}
return MPhoto::createPhotoForExternalResource($url);
$mimetext = '';
if (!empty($url)) {
$mime = ParseUrl::getContentType($url);
if (empty($mime) || ($mime[0] != 'image')) {
$url = '';
} else {
$mimetext = $mime[0] . '/' . $mime[1];
}
}
if (empty($url)) {
if ($customsize <= Proxy::PIXEL_MICRO) {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
} elseif ($customsize <= Proxy::PIXEL_THUMB) {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
} else {
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
}
}
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext);
case "header":
$contact = Contact::getById($id, ['uid', 'url', 'header']);
if (empty($contact)) {