Actorの取得失敗をちゃんと無視するように

This commit is contained in:
unarist 2019-02-11 01:43:29 +09:00
parent 1ba4999a83
commit 3584625b47

View File

@ -3,6 +3,8 @@
namespace App\MetadataResolver; namespace App\MetadataResolver;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\TransferException;
use Illuminate\Support\Facades\Log;
class ActivityPubResolver implements Resolver, Parser class ActivityPubResolver implements Resolver, Parser
{ {
@ -46,8 +48,10 @@ class ActivityPubResolver implements Resolver, Parser
private function getTitleFromActor(string $url): string private function getTitleFromActor(string $url): string
{ {
try {
$res = $this->activityClient->get($url); $res = $this->activityClient->get($url);
if ($res->getStatusCode() !== 200) { if ($res->getStatusCode() !== 200) {
Log::info(self::class . ': Actorの取得に失敗 URL=' . $url);
return ''; return '';
} }
@ -58,6 +62,10 @@ class ActivityPubResolver implements Resolver, Parser
} }
return $title; return $title;
} catch (TransferException $e) {
Log::info(self::class . ': Actorの取得に失敗 URL=' . $url);
return '';
}
} }
private function html2text(string $html): string private function html2text(string $html): string