mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update HashtagFollowObserver
This commit is contained in:
parent
c6a6b3ae30
commit
19233cc976
3 changed files with 15 additions and 5 deletions
|
@ -3831,7 +3831,7 @@ class ApiV1Controller extends Controller
|
|||
if($follows) {
|
||||
HashtagService::unfollow($pid, $tag->id);
|
||||
HashtagFollowService::unfollow($tag->id, $pid);
|
||||
HashtagUnfollowPipeline::dispatch($tag->id, $pid)->onQueue('feed');
|
||||
HashtagUnfollowPipeline::dispatch($tag->id, $pid, $tag->slug)->onQueue('feed');
|
||||
$follows->delete();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class HashtagUnfollowPipeline implements ShouldQueue
|
|||
|
||||
protected $pid;
|
||||
protected $hid;
|
||||
protected $slug;
|
||||
|
||||
public $timeout = 900;
|
||||
public $tries = 3;
|
||||
|
@ -33,10 +34,11 @@ class HashtagUnfollowPipeline implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct($hid, $pid)
|
||||
public function __construct($hid, $pid, $slug)
|
||||
{
|
||||
$this->hid = $hid;
|
||||
$this->pid = $pid;
|
||||
$this->slug = $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,6 +48,7 @@ class HashtagUnfollowPipeline implements ShouldQueue
|
|||
{
|
||||
$hid = $this->hid;
|
||||
$pid = $this->pid;
|
||||
$slug = $this->slug;
|
||||
|
||||
$statusIds = HomeTimelineService::get($pid, 0, -1);
|
||||
|
||||
|
@ -60,7 +63,16 @@ class HashtagUnfollowPipeline implements ShouldQueue
|
|||
HomeTimelineService::rem($pid, $id);
|
||||
continue;
|
||||
}
|
||||
if(!in_array($status['account']['id'], $followingIds)) {
|
||||
$following = in_array($status['account']['id'], $followingIds);
|
||||
if($following || !isset($status['tags'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tags = collect($status['tags'])->filter(function($tag) {
|
||||
return $tag['name'];
|
||||
})->toArray();
|
||||
|
||||
if(in_array($slug, $tags)) {
|
||||
HomeTimelineService::rem($pid, $id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ class HashtagFollowObserver implements ShouldHandleEventsAfterCommit
|
|||
public function deleting(HashtagFollow $hashtagFollow): void
|
||||
{
|
||||
HashtagFollowService::unfollow($hashtagFollow->hashtag_id, $hashtagFollow->profile_id);
|
||||
HashtagUnfollowPipeline::dispatch($hashtagFollow->hashtag_id, $hashtagFollow->profile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,6 +47,5 @@ class HashtagFollowObserver implements ShouldHandleEventsAfterCommit
|
|||
public function forceDeleted(HashtagFollow $hashtagFollow): void
|
||||
{
|
||||
HashtagFollowService::unfollow($hashtagFollow->hashtag_id, $hashtagFollow->profile_id);
|
||||
HashtagUnfollowPipeline::dispatch($hashtagFollow->hashtag_id, $hashtagFollow->profile_id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue