mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-12 17:44:31 +00:00
Update FollowRequest model
This commit is contained in:
parent
4f99039c15
commit
85fb46668c
4 changed files with 37 additions and 7 deletions
|
@ -6,7 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class FollowRequest extends 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()
|
public function follower()
|
||||||
{
|
{
|
||||||
|
@ -27,4 +31,10 @@ class FollowRequest extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Profile::class, 'following_id', 'id');
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,6 @@ class FollowPipeline implements ShouldQueue
|
||||||
$notification->item_id = $target->id;
|
$notification->item_id = $target->id;
|
||||||
$notification->item_type = "App\Profile";
|
$notification->item_type = "App\Profile";
|
||||||
$notification->save();
|
$notification->save();
|
||||||
|
|
||||||
$redis = Redis::connection();
|
|
||||||
|
|
||||||
$nkey = config('cache.prefix').':user.'.$target->id.'.notifications';
|
|
||||||
$redis->lpush($nkey, $notification->id);
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error($e);
|
Log::error($e);
|
||||||
}
|
}
|
||||||
|
|
25
app/Transformer/ActivityPub/Verb/AcceptFollow.php
Normal file
25
app/Transformer/ActivityPub/Verb/AcceptFollow.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformer\ActivityPub\Verb;
|
||||||
|
|
||||||
|
use App\FollowRequest;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
class AcceptFollow extends Fractal\TransformerAbstract
|
||||||
|
{
|
||||||
|
public function transform(FollowRequest $follow)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'@context' => '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()
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -477,7 +477,7 @@ class Inbox
|
||||||
'follower_id' => $actor->id,
|
'follower_id' => $actor->id,
|
||||||
'following_id' => $target->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 {
|
} else {
|
||||||
$follower = new Follower;
|
$follower = new Follower;
|
||||||
|
|
Loading…
Reference in a new issue