Selaa lähdekoodia

Update ImportService, filter deleted posts from getImportedPosts endpoint

Daniel Supernault 2 vuotta sitten
vanhempi
commit
10dd348c28
2 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 1 0
      app/Observers/StatusObserver.php
  2. 4 1
      app/Services/ImportService.php

+ 1 - 0
app/Observers/StatusObserver.php

@@ -59,6 +59,7 @@ class StatusObserver
         ProfileStatusService::delete($status->profile_id, $status->id);
 
         if($status->uri == null) {
+            ImportPost::whereProfileId($status->profile_id)->whereStatusId($status->id)->delete();
             ImportService::clearImportedFiles($status->profile_id);
         }
     }

+ 4 - 1
app/Services/ImportService.php

@@ -97,9 +97,12 @@ class ImportService
         return Cache::remember($key, 21600, function() use($profileId) {
             return ImportPost::whereProfileId($profileId)
                 ->get()
+                ->filter(function($ip) {
+                    return StatusService::get($ip->status_id);
+                })
                 ->map(function($ip) {
                     return collect($ip->media)->map(function($m) { return $m['uri']; });
-                })->flatten();
+                })->values()->flatten();
         });
     }