Merge remote-tracking branch 'upstream/2023.05-rc' into receiver-exception

This commit is contained in:
Michael 2023-05-19 17:44:01 +00:00
commit 63436be80e
12 changed files with 253 additions and 237 deletions

View file

@ -1 +1 @@
2023.06-dev 2023.05-rc

View file

@ -375,9 +375,7 @@ function photos_post(App $a)
$arr['visible'] = 0; $arr['visible'] = 0;
$arr['origin'] = 1; $arr['origin'] = 1;
$arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $photo['resource-id'] . ']' $arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
. '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $photo['scale'] . '.'. $ext . '[/img]'
. '[/url]';
$item_id = Item::insert($arr); $item_id = Item::insert($arr);
} }

View file

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

View file

@ -378,7 +378,11 @@ class Item
'url' => $item['author-link'], 'url' => $item['author-link'],
]; ];
$profile_link = Contact::magicLinkByContact($author, $item['author-link']); $profile_link = Contact::magicLinkByContact($author, $item['author-link']);
$sparkle = (strpos($profile_link, 'contact/redir/') === 0); if (strpos($profile_link, 'contact/redir/') === 0) {
$status_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']);
$profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
}
$cid = 0; $cid = 0;
$pcid = $item['author-id']; $pcid = $item['author-id'];
@ -392,12 +396,6 @@ class Item
$rel = $contact['rel']; $rel = $contact['rel'];
} }
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (!empty($pcid)) { if (!empty($pcid)) {
$contact_url = 'contact/' . $pcid; $contact_url = 'contact/' . $pcid;
$posts_link = $contact_url . '/posts'; $posts_link = $contact_url . '/posts';

View file

@ -24,7 +24,6 @@ namespace Friendica\Content\Text;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
use Friendica\Protocol\HTTP\MediaType; use Friendica\Protocol\HTTP\MediaType;
use Friendica\Content\Widget\ContactBlock;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;

View file

@ -1152,10 +1152,11 @@ class Contact
$status_link = ''; $status_link = '';
$photos_link = ''; $photos_link = '';
$sparkle = false;
if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) { if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) {
$sparkle = true;
$profile_link = 'contact/redir/' . $contact['id']; $profile_link = 'contact/redir/' . $contact['id'];
$status_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/photos']);
$profile_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/profile']);
} else { } else {
$profile_link = $contact['url']; $profile_link = $contact['url'];
} }
@ -1164,12 +1165,6 @@ class Contact
$profile_link = ''; $profile_link = '';
} }
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) { if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) {
$pm_url = 'message/new/' . $contact['id']; $pm_url = 'message/new/' . $contact['id'];
} }
@ -3444,7 +3439,7 @@ class Contact
*/ */
public static function magicLinkByContact(array $contact, string $url = ''): string public static function magicLinkByContact(array $contact, string $url = ''): string
{ {
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url']; $destination = $url ?: $contact['url'];
if (!DI::userSession()->isAuthenticated()) { if (!DI::userSession()->isAuthenticated()) {
return $destination; return $destination;

View file

@ -489,7 +489,7 @@ class Media
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) { if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) { foreach ($pictures as $picture) {
if (self::isLinkToImagePage($picture[1], $picture[2])) { if (self::isLinkToImagePage($picture[1], $picture[2])) {
$body = str_replace($picture[0], '[url=' . str_replace(['-1.', '-2.'], '-0.', $picture[2]) . '][img=' . $picture[2] . ']' . $picture[3] . '[/img][/url]', $body); $body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2], $picture[3]), $body);
} }
} }
} }
@ -497,7 +497,7 @@ class Media
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) { if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) { foreach ($pictures as $picture) {
if (self::isLinkToImagePage($picture[1], $picture[2])) { if (self::isLinkToImagePage($picture[1], $picture[2])) {
$body = str_replace($picture[0], '[url=' . str_replace(['-1.', '-2.'], '-0.', $picture[2]) . '][img]' . $picture[2] . '[/img][/url]', $body); $body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2]), $body);
} }
} }
} }
@ -1004,19 +1004,7 @@ class Media
} }
if ($media['type'] == self::IMAGE) { if ($media['type'] == self::IMAGE) {
if (!empty($media['preview'])) { $body .= "\n" . Images::getBBCodeByUrl($media['url'], $media['preview'], $media['description'] ?? '');
if (!empty($media['description'])) {
$body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] . '[/img][/url]';
} else {
$body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] . '[/img][/url]';
}
} else {
if (!empty($media['description'])) {
$body .= "\n[img=" . $media['url'] . ']' . $media['description'] . '[/img]';
} else {
$body .= "\n[img]" . $media['url'] . '[/img]';
}
}
} elseif ($media['type'] == self::AUDIO) { } elseif ($media['type'] == self::AUDIO) {
$body .= "\n[audio]" . $media['url'] . "[/audio]\n"; $body .= "\n[audio]" . $media['url'] . "[/audio]\n";
} elseif ($media['type'] == self::VIDEO) { } elseif ($media['type'] == self::VIDEO) {

View file

@ -34,7 +34,6 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
@ -180,7 +179,7 @@ class Upload extends \Friendica\BaseModule
} }
$this->logger->info('upload done'); $this->logger->info('upload done');
$this->return(200, "\n\n" . '[url=' . $this->baseUrl . '/photos/' . $owner['nickname'] . '/image/' . $resource_id . '][img=' . $this->baseUrl . "/photo/$resource_id-$preview." . $image->getExt() . "][/img][/url]\n\n"); $this->return(200, "\n\n" . Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt()) . "\n\n");
} }
/** /**

View file

@ -273,9 +273,7 @@ class Photos extends \Friendica\Module\BaseProfile
$arr['visible'] = $visible; $arr['visible'] = $visible;
$arr['origin'] = 1; $arr['origin'] = 1;
$arr['body'] = '[url=' . $this->baseUrl . '/photos/' . $this->owner['nickname'] . '/image/' . $resource_id . ']' $arr['body'] = Images::getBBCodeByResource($resource_id, $this->owner['nickname'], $preview, $image->getExt());
. '[img]' . $this->baseUrl . "/photo/{$resource_id}-{$preview}.".$image->getExt() . '[/img]'
. '[/url]';
$item_id = Item::insert($arr); $item_id = Item::insert($arr);
// Update the photo albums cache // Update the photo albums cache

View file

@ -316,4 +316,40 @@ class Images
return ['width' => $dest_width, 'height' => $dest_height]; return ['width' => $dest_width, 'height' => $dest_height];
} }
/**
* Get a BBCode tag for an local photo page URL with a preview thumbnail and an image description
*
* @param string $resource_id
* @param string $nickname The local user owner of the resource
* @param int $preview Preview image size identifier, either 0, 1 or 2 in decreasing order of size
* @param string $ext Image file extension
* @param string $description
* @return string
*/
public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = ''): string
{
return self::getBBCodeByUrl(
DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id,
DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview. '.' . $ext,
$description
);
}
/**
* Get a BBCode tag for an image URL with a preview thumbnail and an image description
*
* @param string $photo Full image URL
* @param string $preview Preview image URL
* @param string $description
* @return string
*/
public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string
{
if (!empty($preview)) {
return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
}
return '[img=' . $photo . ']' . $description . '[/img]';
}
} }

File diff suppressed because it is too large Load diff

View file

@ -1626,7 +1626,6 @@ $a->strings['Or - did you try to upload an empty file?'] = 'Lub - czy próbował
$a->strings['File exceeds size limit of %s'] = 'Plik przekracza limit rozmiaru wynoszący %s'; $a->strings['File exceeds size limit of %s'] = 'Plik przekracza limit rozmiaru wynoszący %s';
$a->strings['File upload failed.'] = 'Przesyłanie pliku nie powiodło się.'; $a->strings['File upload failed.'] = 'Przesyłanie pliku nie powiodło się.';
$a->strings['Unable to process image.'] = 'Przetwarzanie obrazu nie powiodło się.'; $a->strings['Unable to process image.'] = 'Przetwarzanie obrazu nie powiodło się.';
$a->strings['Image exceeds size limit of %s'] = 'Obraz przekracza limit rozmiaru wynoszący %s';
$a->strings['Image upload failed.'] = 'Przesyłanie obrazu nie powiodło się.'; $a->strings['Image upload failed.'] = 'Przesyłanie obrazu nie powiodło się.';
$a->strings['List of all users'] = 'Lista wszystkich użytkowników'; $a->strings['List of all users'] = 'Lista wszystkich użytkowników';
$a->strings['Active'] = 'Aktywne'; $a->strings['Active'] = 'Aktywne';
@ -1880,6 +1879,7 @@ $a->strings['No contacts.'] = 'Brak kontaktów.';
$a->strings['%s\'s timeline'] = 'oś czasu %s'; $a->strings['%s\'s timeline'] = 'oś czasu %s';
$a->strings['%s\'s posts'] = 'wpisy %s'; $a->strings['%s\'s posts'] = 'wpisy %s';
$a->strings['%s\'s comments'] = 'komentarze %s'; $a->strings['%s\'s comments'] = 'komentarze %s';
$a->strings['Image exceeds size limit of %s'] = 'Obraz przekracza limit rozmiaru wynoszący %s';
$a->strings['Image upload didn\'t complete, please try again'] = 'Przesyłanie zdjęć nie zostało zakończone, spróbuj ponownie'; $a->strings['Image upload didn\'t complete, please try again'] = 'Przesyłanie zdjęć nie zostało zakończone, spróbuj ponownie';
$a->strings['Image file is missing'] = 'Brak pliku obrazu'; $a->strings['Image file is missing'] = 'Brak pliku obrazu';
$a->strings['Server can\'t accept new file upload at this time, please contact your administrator'] = 'Serwer nie może teraz przyjąć nowego pliku, skontaktuj się z administratorem'; $a->strings['Server can\'t accept new file upload at this time, please contact your administrator'] = 'Serwer nie może teraz przyjąć nowego pliku, skontaktuj się z administratorem';