mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update LikePipeline
This commit is contained in:
parent
023d279b60
commit
e5683f94d4
1 changed files with 28 additions and 7 deletions
|
@ -2,16 +2,17 @@
|
||||||
|
|
||||||
namespace App\Jobs\LikePipeline;
|
namespace App\Jobs\LikePipeline;
|
||||||
|
|
||||||
use App\Like;
|
use Cache, Log, Redis;
|
||||||
use App\Notification;
|
use App\{Like, Notification};
|
||||||
use Cache;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Log;
|
use App\Util\ActivityPub\Helpers;
|
||||||
use Redis;
|
use League\Fractal;
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
use App\Transformer\ActivityPub\Verb\Like as LikeTransformer;
|
||||||
|
|
||||||
class LikePipeline implements ShouldQueue
|
class LikePipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -48,11 +49,15 @@ class LikePipeline implements ShouldQueue
|
||||||
$status = $this->like->status;
|
$status = $this->like->status;
|
||||||
$actor = $this->like->actor;
|
$actor = $this->like->actor;
|
||||||
|
|
||||||
if (!$status || $status->url !== null) {
|
if (!$status) {
|
||||||
// Ignore notifications to remote statuses, or deleted statuses
|
// Ignore notifications to deleted statuses
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($status->url && $actor->domain == null) {
|
||||||
|
return $this->remoteLikeDeliver();
|
||||||
|
}
|
||||||
|
|
||||||
$exists = Notification::whereProfileId($status->profile_id)
|
$exists = Notification::whereProfileId($status->profile_id)
|
||||||
->whereActorId($actor->id)
|
->whereActorId($actor->id)
|
||||||
->whereAction('like')
|
->whereAction('like')
|
||||||
|
@ -78,4 +83,20 @@ class LikePipeline implements ShouldQueue
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function remoteLikeDeliver()
|
||||||
|
{
|
||||||
|
$like = $this->like;
|
||||||
|
$status = $this->like->status;
|
||||||
|
$actor = $this->like->actor;
|
||||||
|
|
||||||
|
$fractal = new Fractal\Manager();
|
||||||
|
$fractal->setSerializer(new ArraySerializer());
|
||||||
|
$resource = new Fractal\Resource\Item($like, new LikeTransformer());
|
||||||
|
$activity = $fractal->createData($resource)->toArray();
|
||||||
|
|
||||||
|
$url = $status->profile->sharedInbox ?? $status->profile->inbox_url;
|
||||||
|
|
||||||
|
Helpers::sendSignedObject($actor, $url, $activity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue