diff --git a/app/FollowRequest.php b/app/FollowRequest.php index 89bd26e9a..7852e2688 100644 --- a/app/FollowRequest.php +++ b/app/FollowRequest.php @@ -6,7 +6,11 @@ use Illuminate\Database\Eloquent\Model; class FollowRequest extends Model { - protected $fillable = ['follower_id', 'following_id']; + protected $fillable = ['follower_id', 'following_id', 'activity', 'handled_at']; + + protected $casts = [ + 'activity' => 'array', + ]; public function follower() { @@ -27,4 +31,10 @@ class FollowRequest extends Model { return $this->belongsTo(Profile::class, 'following_id', 'id'); } + + public function permalink($append = null) + { + $path = $this->target->permalink("#accepts/follows/{$this->id}{$append}"); + return url($path); + } } diff --git a/app/Jobs/FollowPipeline/FollowPipeline.php b/app/Jobs/FollowPipeline/FollowPipeline.php index 986f22425..f2bab5a96 100644 --- a/app/Jobs/FollowPipeline/FollowPipeline.php +++ b/app/Jobs/FollowPipeline/FollowPipeline.php @@ -63,11 +63,6 @@ class FollowPipeline implements ShouldQueue $notification->item_id = $target->id; $notification->item_type = "App\Profile"; $notification->save(); - - $redis = Redis::connection(); - - $nkey = config('cache.prefix').':user.'.$target->id.'.notifications'; - $redis->lpush($nkey, $notification->id); } catch (Exception $e) { Log::error($e); } diff --git a/app/Transformer/ActivityPub/Verb/AcceptFollow.php b/app/Transformer/ActivityPub/Verb/AcceptFollow.php new file mode 100644 index 000000000..cb5b54a41 --- /dev/null +++ b/app/Transformer/ActivityPub/Verb/AcceptFollow.php @@ -0,0 +1,25 @@ + 'https://www.w3.org/ns/activitystreams', + 'type' => 'Accept', + 'id' => $follow->permalink(), + 'actor' => $follow->target->permalink(), + 'object' => [ + 'type' => 'Follow', + 'id' => $follow->activity ? $follow->activity['id'] : null, + 'actor' => $follow->actor->permalink(), + 'object' => $follow->target->permalink() + ] + ]; + } +} diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index a874a39fe..2d48cb97f 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -477,7 +477,7 @@ class Inbox 'follower_id' => $actor->id, 'following_id' => $target->id, ],[ - 'activity' => collect($this->payload)->only(['id','actor','object'])->toArray() + 'activity' => collect($this->payload)->only(['id','actor','object','type'])->toArray() ]); } else { $follower = new Follower;