Don't try to follow remote item from non-URI or scheme-less URI
- Address https://github.com/friendica/friendica/issues/12486#issuecomment-1407679388 - Address https://github.com/friendica/friendica/issues/12486#issuecomment-1433112562
This commit is contained in:
parent
1a21f19f42
commit
8ab5fddafd
|
@ -40,6 +40,7 @@ use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use GuzzleHttp\Psr7\Uri;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Follow extends BaseModule
|
class Follow extends BaseModule
|
||||||
|
@ -223,17 +224,26 @@ class Follow extends BaseModule
|
||||||
|
|
||||||
protected function followRemoteItem(string $url)
|
protected function followRemoteItem(string $url)
|
||||||
{
|
{
|
||||||
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
|
try {
|
||||||
if (!$itemId) {
|
$uri = new Uri($url);
|
||||||
// If the user-specific search failed, we search and probe a public post
|
if (!$uri->getScheme()) {
|
||||||
$itemId = Item::fetchByLink($url);
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($itemId)) {
|
|
||||||
$item = Post::selectFirst(['guid'], ['id' => $itemId]);
|
|
||||||
if (!empty($item['guid'])) {
|
|
||||||
$this->baseUrl->redirect('display/' . $item['guid']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
|
||||||
|
if (!$itemId) {
|
||||||
|
// If the user-specific search failed, we search and probe a public post
|
||||||
|
$itemId = Item::fetchByLink($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($itemId)) {
|
||||||
|
$item = Post::selectFirst(['guid'], ['id' => $itemId]);
|
||||||
|
if (!empty($item['guid'])) {
|
||||||
|
$this->baseUrl->redirect('display/' . $item['guid']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue