Explorar el Código

Update AP Inbox

Daniel Supernault hace 6 años
padre
commit
d11c71cdec
Se han modificado 1 ficheros con 27 adiciones y 1 borrados
  1. 27 1
      app/Util/ActivityPub/Inbox.php

+ 27 - 1
app/Util/ActivityPub/Inbox.php

@@ -271,7 +271,19 @@ class Inbox
 
 
     public function handleDeleteActivity()
     public function handleDeleteActivity()
     {
     {
+        $actor = $this->payload['actor'];
+        $obj = $this->payload['object'];
+        if(is_string($obj) && Helpers::validateUrl($obj)) {
+            // actor object detected
 
 
+        } else if (is_array($obj) && isset($obj['type']) && $obj['type'] == 'Tombstone') {
+            // tombstone detected
+            $status = Status::whereUri($obj['id'])->first();
+            if($status == null) {
+                return;
+            }
+            $status->forceDelete();
+        }
     }
     }
 
 
     public function handleLikeActivity()
     public function handleLikeActivity()
@@ -311,7 +323,21 @@ class Inbox
                 $status = Helpers::statusFirstOrFetch($obj['object']);
                 $status = Helpers::statusFirstOrFetch($obj['object']);
                 Like::whereProfileId($profile->id)
                 Like::whereProfileId($profile->id)
                     ->whereStatusId($status->id)
                     ->whereStatusId($status->id)
-                    ->delete();
+                    ->forceDelete();
+                break;
+                
+            case 'Announce':
+                $parent = Helpers::statusFirstOrFetch($obj['object']);
+                $status = Status::whereProfileId($profile->id)
+                    ->whereReblogOfId($parent->id)
+                    ->first();
+                Notification::whereProfileId($parent->profile->id)
+                    ->whereActorId($profile->id)
+                    ->whereAction('share')
+                    ->whereItemId($status->id)
+                    ->whereItemType('App\Status')
+                    ->forceDelete();
+                $status->forceDelete();
                 break;
                 break;
         }
         }