1
0
Fork 0
forked from mirror/pixelfed

Update AP Helpers

This commit is contained in:
Daniel Supernault 2021-01-28 21:26:45 -07:00
parent 7d376c64ec
commit fa0df4004c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -245,7 +245,8 @@ class Helpers {
if($local) { if($local) {
$id = (int) last(explode('/', $url)); $id = (int) last(explode('/', $url));
return Status::whereNotIn('scope', ['draft','archived'])->findOrFail($id); return Status::whereNotIn('scope', ['draft','archived'])->findOrFail($id);
} else { }
$cached = Status::whereNotIn('scope', ['draft','archived']) $cached = Status::whereNotIn('scope', ['draft','archived'])
->whereUri($url) ->whereUri($url)
->orWhere('object_url', $url) ->orWhere('object_url', $url)
@ -295,7 +296,7 @@ class Helpers {
$keywords = config('costar.keyword.block'); $keywords = config('costar.keyword.block');
foreach($keywords as $kw) { foreach($keywords as $kw) {
if(Str::contains($res['content'], $kw) == true) { if(Str::contains($res['content'], $kw) == true) {
abort(400, 'Invalid object'); return;
} }
} }
} }
@ -315,21 +316,25 @@ class Helpers {
} }
$id = isset($res['id']) ? $res['id'] : $url; $id = isset($res['id']) ? $res['id'] : $url;
$idDomain = parse_url($id, PHP_URL_HOST);
$urlDomain = parse_url($url, PHP_URL_HOST);
if(!self::validateUrl($id) || if(!self::validateUrl($id)) {
!self::validateUrl($activity['object']['attributedTo'])
) {
return; return;
} }
$idDomain = parse_url($id, PHP_URL_HOST); if(isset($activity['object']['attributedTo'])) {
$urlDomain = parse_url($url, PHP_URL_HOST);
$actorDomain = parse_url($activity['object']['attributedTo'], PHP_URL_HOST); $actorDomain = parse_url($activity['object']['attributedTo'], PHP_URL_HOST);
if(!self::validateUrl($activity['object']['attributedTo']) ||
$idDomain !== $actorDomain)
{
return;
}
}
if( if(
$idDomain !== $urlDomain || $idDomain !== $urlDomain ||
$actorDomain !== $urlDomain || $actorDomain !== $urlDomain
$idDomain !== $actorDomain
) { ) {
return; return;
} }
@ -365,10 +370,8 @@ class Helpers {
return $status; return $status;
}); });
return $status; return $status;
} }
}
public static function statusFetch($url) public static function statusFetch($url)
{ {