pull/735/head
Daniel Supernault 2018-12-31 23:28:34 -07:00
rodzic 3e6961ca67
commit edb12964f6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
1 zmienionych plików z 4 dodań i 31 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
namespace App\Util\ActivityPub; namespace App\Util\ActivityPub;
use Cache, DB, Log, Redis, Validator; use Cache, DB, Log, Purify, Redis, Validator;
use App\{ use App\{
Activity, Activity,
Follower, Follower,
@ -35,30 +35,6 @@ class Inbox
$this->handleVerb(); $this->handleVerb();
} }
public function authenticatePayload()
{
try {
$signature = Helpers::validateSignature($this->headers, $this->payload);
$payload = Helpers::validateObject($this->payload);
if($signature == false) {
return;
}
} catch (Exception $e) {
return;
}
$this->payloadLogger();
}
public function payloadLogger()
{
$logger = new Activity;
$logger->data = json_encode($this->payload);
$logger->save();
$this->logger = $logger;
Log::info('AP:inbox:activity:new:'.$this->logger->id);
$this->handleVerb();
}
public function handleVerb() public function handleVerb()
{ {
$verb = $this->payload['type']; $verb = $this->payload['type'];
@ -171,7 +147,7 @@ class Inbox
$caption = str_limit(strip_tags($activity['content']), config('pixelfed.max_caption_length')); $caption = str_limit(strip_tags($activity['content']), config('pixelfed.max_caption_length'));
$status = new Status; $status = new Status;
$status->profile_id = $actor->id; $status->profile_id = $actor->id;
$status->caption = $caption; $status->caption = Purify::clean($caption);
$status->visibility = $status->scope = 'public'; $status->visibility = $status->scope = 'public';
$status->uri = $url; $status->uri = $url;
$status->url = $url; $status->url = $url;
@ -275,13 +251,10 @@ class Inbox
$obj = $this->payload['object']; $obj = $this->payload['object'];
if(is_string($obj) && Helpers::validateUrl($obj)) { if(is_string($obj) && Helpers::validateUrl($obj)) {
// actor object detected // actor object detected
// todo delete actor
} else if (is_array($obj) && isset($obj['type']) && $obj['type'] == 'Tombstone') { } else if (is_array($obj) && isset($obj['type']) && $obj['type'] == 'Tombstone') {
// tombstone detected // tombstone detected
$status = Status::whereUri($obj['id'])->first(); $status = Status::whereUri($obj['id'])->firstOrFail();
if($status == null) {
return;
}
$status->forceDelete(); $status->forceDelete();
} }
} }