diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php
index 299c263994..fc4b7e38cb 100644
--- a/src/Contact/Avatar.php
+++ b/src/Contact/Avatar.php
@@ -92,7 +92,7 @@ class Avatar
return $fields;
}
- $filename = self::getFilename($contact['url']);
+ $filename = self::getFilename($contact['url'], $avatar);
$timestamp = time();
$fields['blurhash'] = $image->getBlurHash();
@@ -120,7 +120,7 @@ class Avatar
return $fields;
}
- $filename = self::getFilename($contact['url']);
+ $filename = self::getFilename($contact['url'], $contact['avatar']);
$timestamp = time();
$fields['photo'] = self::storeAvatarCache($image, $filename, Proxy::PIXEL_SMALL, $timestamp);
@@ -130,9 +130,9 @@ class Avatar
return $fields;
}
- private static function getFilename(string $url): string
+ private static function getFilename(string $url, string $host): string
{
- $guid = Item::guidFromUri($url);
+ $guid = Item::guidFromUri($url, $host);
return substr($guid, 0, 2) . '/' . substr($guid, 3, 2) . '/' . substr($guid, 5, 3) . '/' .
substr($guid, 9, 2) .'/' . substr($guid, 11, 2) . '/' . substr($guid, 13, 4). '/' . substr($guid, 18) . '-';
diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index 0e5ee9d4e2..e321b13e70 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -62,6 +62,7 @@ class BBCode
const TWITTER = 8;
const BACKLINK = 8;
const ACTIVITYPUB = 9;
+ const BLUESKY = 10;
const TOP_ANCHOR = '
';
const BOTTOM_ANCHOR = '
';
@@ -1771,7 +1772,7 @@ class BBCode
$text
);
- if (in_array($simple_html, [self::OSTATUS, self::TWITTER])) {
+ if (in_array($simple_html, [self::OSTATUS, self::TWITTER, self::BLUESKY])) {
$text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", [self::class, 'expandLinksCallback'], $text);
//$text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $text);
$text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]', $text);
diff --git a/src/Content/Text/Plaintext.php b/src/Content/Text/Plaintext.php
index b297f75b36..86d720a02a 100644
--- a/src/Content/Text/Plaintext.php
+++ b/src/Content/Text/Plaintext.php
@@ -137,6 +137,10 @@ class Plaintext
$abstract = BBCode::getAbstract($item['body'], Protocol::STATUSNET);
break;
+ case BBCode::BLUESKY:
+ $abstract = BBCode::getAbstract($item['body'], Protocol::BLUESKY);
+ break;
+
default: // We don't know the exact target.
// We fetch an abstract since there is a posting limit.
if ($limit > 0) {
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index 3f830c29a4..720d2638c4 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -2773,7 +2773,7 @@ class Contact
}
$update = false;
- $guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url']);
+ $guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], $ret['baseurl'] ?: $ret['alias']);
// make sure to not overwrite existing values with blank entries except some technical fields
$keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl'];
diff --git a/src/Model/Item.php b/src/Model/Item.php
index fad8ffeff4..cdeb6d3d13 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -2044,7 +2044,7 @@ class Item
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
unset($parsed['scheme']);
- $hostPart = $host ?? $parsed['host'] ?? '';
+ $hostPart = $host ?: $parsed['host'] ?? '';
if (!$hostPart) {
Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed, 'callstack' => System::callstack(10)]);
}
diff --git a/src/Protocol/Relay.php b/src/Protocol/Relay.php
index d8b11cf95b..c5131fb3fd 100644
--- a/src/Protocol/Relay.php
+++ b/src/Protocol/Relay.php
@@ -135,22 +135,8 @@ class Relay
}
}
- $languages = [];
- foreach (Item::getLanguageArray($body, 10) as $language => $reliability) {
- if ($reliability > 0) {
- $languages[] = $language;
- }
- }
-
- Logger::debug('Got languages', ['languages' => $languages, 'body' => $body, 'causer' => $causer]);
-
- if (!empty($languages)) {
- if (in_array($languages[0], $config->get('system', 'relay_deny_languages'))) {
- Logger::info('Unwanted language found - rejected', ['language' => $languages[0], 'network' => $network, 'url' => $url, 'causer' => $causer]);
- return false;
- }
- } elseif ($config->get('system', 'relay_deny_undetected_language')) {
- Logger::info('Undetected language found - rejected', ['body' => $body, 'network' => $network, 'url' => $url, 'causer' => $causer]);
+ if (!self::isWantedLanguage($body)) {
+ Logger::info('Unwanted or Undetected language found - rejected', ['network' => $network, 'url' => $url, 'causer' => $causer]);
return false;
}
@@ -163,6 +149,36 @@ class Relay
return false;
}
+ /**
+ * Detect the language of a post and decide if the post should be accepted
+ *
+ * @param string $body
+ * @return boolean
+ */
+ public static function isWantedLanguage(string $body)
+ {
+ $languages = [];
+ foreach (Item::getLanguageArray($body, 10) as $language => $reliability) {
+ if ($reliability > 0) {
+ $languages[] = $language;
+ }
+ }
+
+ Logger::debug('Got languages', ['languages' => $languages, 'body' => $body]);
+
+ if (!empty($languages)) {
+ if (in_array($languages[0], DI::config()->get('system', 'relay_deny_languages'))) {
+ Logger::info('Unwanted language found', ['language' => $languages[0]]);
+ return false;
+ }
+ } elseif (DI::config()->get('system', 'relay_deny_undetected_language')) {
+ Logger::info('Undetected language found', ['body' => $body]);
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Update or insert a relay contact
*