mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update StatusDelete pipeline, fanout via AP if enabled
This commit is contained in:
parent
6b2955561e
commit
66d525dde5
2 changed files with 53 additions and 1 deletions
|
@ -13,6 +13,10 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use League\Fractal;
|
||||
use League\Fractal\Serializer\ArraySerializer;
|
||||
use App\Transformer\ActivityPub\Verb\DeleteNote;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
|
||||
class StatusDelete implements ShouldQueue
|
||||
{
|
||||
|
@ -46,7 +50,12 @@ class StatusDelete implements ShouldQueue
|
|||
{
|
||||
$status = $this->status;
|
||||
|
||||
$this->unlinkRemoveMedia($status);
|
||||
if(config('pixelfed.activitypub_enabled') == true) {
|
||||
$this->fanoutDelete($status);
|
||||
} else {
|
||||
$this->unlinkRemoveMedia($status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function unlinkRemoveMedia($status)
|
||||
|
@ -87,4 +96,22 @@ class StatusDelete implements ShouldQueue
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function fanoutDelete($status)
|
||||
{
|
||||
$audience = $status->profile->getAudienceInbox();
|
||||
$profile = $status->profile;
|
||||
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Item($status, new DeleteNote());
|
||||
$activity = $fractal->createData($resource)->toArray();
|
||||
|
||||
$this->unlinkRemoveMedia($status);
|
||||
|
||||
foreach($audience as $url) {
|
||||
Helpers::sendSignedObject($profile, $url, $activity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
25
app/Transformer/ActivityPub/Verb/DeleteNote.php
Normal file
25
app/Transformer/ActivityPub/Verb/DeleteNote.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Transformer\ActivityPub\Verb;
|
||||
|
||||
use App\Status;
|
||||
use League\Fractal;
|
||||
|
||||
class DeleteNote extends Fractal\TransformerAbstract
|
||||
{
|
||||
public function transform(Status $status)
|
||||
{
|
||||
'@context' => [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
],
|
||||
'id' => $status->permalink('#delete'),
|
||||
'type' => 'Delete',
|
||||
'actor' => $status->profile->permalink(),
|
||||
'object' => [
|
||||
'id' => $status->permalink()
|
||||
'type' => 'Tombstone',
|
||||
]
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue