Forráskód Böngészése

Update HashtagFollowObserver

Daniel Supernault 1 éve
szülő
commit
19233cc976

+ 1 - 1
app/Http/Controllers/Api/ApiV1Controller.php

@@ -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();
 		}
 

+ 14 - 2
app/Jobs/HomeFeedPipeline/HashtagUnfollowPipeline.php

@@ -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);
             }
         }

+ 0 - 2
app/Observers/HashtagFollowObserver.php

@@ -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);
     }
 }