Update HashtagFollowObserver

This commit is contained in:
Daniel Supernault 2023-11-15 22:16:23 -07:00
parent c6a6b3ae30
commit 19233cc976
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
3 changed files with 15 additions and 5 deletions

View file

@ -3831,7 +3831,7 @@ class ApiV1Controller extends Controller
if($follows) { if($follows) {
HashtagService::unfollow($pid, $tag->id); HashtagService::unfollow($pid, $tag->id);
HashtagFollowService::unfollow($tag->id, $pid); HashtagFollowService::unfollow($tag->id, $pid);
HashtagUnfollowPipeline::dispatch($tag->id, $pid)->onQueue('feed'); HashtagUnfollowPipeline::dispatch($tag->id, $pid, $tag->slug)->onQueue('feed');
$follows->delete(); $follows->delete();
} }

View file

@ -24,6 +24,7 @@ class HashtagUnfollowPipeline implements ShouldQueue
protected $pid; protected $pid;
protected $hid; protected $hid;
protected $slug;
public $timeout = 900; public $timeout = 900;
public $tries = 3; public $tries = 3;
@ -33,10 +34,11 @@ class HashtagUnfollowPipeline implements ShouldQueue
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct($hid, $pid) public function __construct($hid, $pid, $slug)
{ {
$this->hid = $hid; $this->hid = $hid;
$this->pid = $pid; $this->pid = $pid;
$this->slug = $slug;
} }
/** /**
@ -46,6 +48,7 @@ class HashtagUnfollowPipeline implements ShouldQueue
{ {
$hid = $this->hid; $hid = $this->hid;
$pid = $this->pid; $pid = $this->pid;
$slug = $this->slug;
$statusIds = HomeTimelineService::get($pid, 0, -1); $statusIds = HomeTimelineService::get($pid, 0, -1);
@ -60,7 +63,16 @@ class HashtagUnfollowPipeline implements ShouldQueue
HomeTimelineService::rem($pid, $id); HomeTimelineService::rem($pid, $id);
continue; 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); HomeTimelineService::rem($pid, $id);
} }
} }

View file

@ -31,7 +31,6 @@ class HashtagFollowObserver implements ShouldHandleEventsAfterCommit
public function deleting(HashtagFollow $hashtagFollow): void public function deleting(HashtagFollow $hashtagFollow): void
{ {
HashtagFollowService::unfollow($hashtagFollow->hashtag_id, $hashtagFollow->profile_id); 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 public function forceDeleted(HashtagFollow $hashtagFollow): void
{ {
HashtagFollowService::unfollow($hashtagFollow->hashtag_id, $hashtagFollow->profile_id); HashtagFollowService::unfollow($hashtagFollow->hashtag_id, $hashtagFollow->profile_id);
HashtagUnfollowPipeline::dispatch($hashtagFollow->hashtag_id, $hashtagFollow->profile_id);
} }
} }