1
0
Fork 0

Add remote follow job

This commit is contained in:
Daniel Supernault 2018-12-31 23:27:07 -07:00
parent 8157668dba
commit 3e6961ca67
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,57 @@
<?php
namespace App\Jobs\FollowPipeline;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Cache, Log, Redis;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use App\FollowRequest;
use App\Util\ActivityPub\Helpers;
use App\Transformer\ActivityPub\Verb\Follow;
class FollowActivityPubDeliver implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $followRequest;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(FollowRequest $followRequest)
{
$this->followRequest = $followRequest;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$follow = $this->followRequest;
$actor = $follow->actor;
$target = $follow->target;
if($target->domain == null || $target->inbox_url == null) {
return;
}
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($follow, new Follow());
$activity = $fractal->createData($resource)->toArray();
$url = $target->sharedInbox ?? $target->inbox_url;
Helpers::sendSignedObject($actor, $url, $activity);
}
}