]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / classes / Notice.php
index 14fffe69763213bd63f47bf3246a0855a745e2f0..0910ba39b7c650b501402569c65b11368970df8e 100644 (file)
@@ -109,6 +109,11 @@ class Notice extends Memcached_DataObject
         // @fixme we have some cases where things get re-run and so the
         // insert fails.
         $deleted = Deleted_notice::staticGet('id', $this->id);
+
+        if (!$deleted) {
+            $deleted = Deleted_notice::staticGet('uri', $this->uri);
+        }
+
         if (!$deleted) {
             $deleted = new Deleted_notice();
 
@@ -130,6 +135,7 @@ class Notice extends Memcached_DataObject
             $this->clearFaves();
             $this->clearTags();
             $this->clearGroupInboxes();
+            $this->clearFiles();
 
             // NOTE: we don't clear inboxes
             // NOTE: we don't clear queue items
@@ -813,9 +819,18 @@ class Notice extends Memcached_DataObject
 
         // Exclude any deleted, non-local, or blocking recipients.
         $profile = $this->getProfile();
+        $originalProfile = null;
+        if ($this->repeat_of) {
+            // Check blocks against the original notice's poster as well.
+            $original = Notice::staticGet('id', $this->repeat_of);
+            if ($original) {
+                $originalProfile = $original->getProfile();
+            }
+        }
         foreach ($ni as $id => $source) {
             $user = User::staticGet('id', $id);
-            if (empty($user) || $user->hasBlocked($profile)) {
+            if (empty($user) || $user->hasBlocked($profile) ||
+                ($originalProfile && $user->hasBlocked($originalProfile))) {
                 unset($ni[$id]);
             }
         }
@@ -1780,6 +1795,21 @@ class Notice extends Memcached_DataObject
         $reply->free();
     }
 
+    function clearFiles()
+    {
+        $f2p = new File_to_post();
+
+        $f2p->post_id = $this->id;
+
+        if ($f2p->find()) {
+            while ($f2p->fetch()) {
+                $f2p->delete();
+            }
+        }
+        // FIXME: decide whether to delete File objects
+        // ...and related (actual) files
+    }
+
     function clearRepeats()
     {
         $repeatNotice = new Notice();