]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge branch '0.9.x' of git@gitorious.org:laconica/mainline into 0.9.x
[quix0rs-gnu-social.git] / classes / Notice.php
index 5ec0692d90e5e3eadffc2da8a529be7263b6347f..c6ad7d6c4568e912e314da8b4bfd9839d9aa579b 100644 (file)
@@ -74,7 +74,21 @@ class Notice extends Memcached_DataObject
         $this->blowFavesCache(true);
         $this->blowSubsCache(true);
 
+        // For auditing purposes, save a record that the notice
+        // was deleted.
+
+        $deleted = new Deleted_notice();
+
+        $deleted->id         = $this->id;
+        $deleted->profile_id = $this->profile_id;
+        $deleted->uri        = $this->uri;
+        $deleted->created    = $this->created;
+        $deleted->deleted    = common_sql_now();
+
         $this->query('BEGIN');
+
+        $deleted->insert();
+
         //Null any notices that are replies to this notice
         $this->query(sprintf("UPDATE notice set reply_to = null WHERE reply_to = %d", $this->id));
         $related = array('Reply',
@@ -356,6 +370,8 @@ class Notice extends Memcached_DataObject
         $this->blowTagCache($blowLast);
         $this->blowGroupCache($blowLast);
         $this->blowConversationCache($blowLast);
+        $profile = Profile::staticGet($this->profile_id);
+        $profile->blowNoticeCount();
     }
 
     function blowConversationCache($blowLast=false)
@@ -873,6 +889,9 @@ class Notice extends Memcached_DataObject
                 }
                 $qry .= '('.$id.', '.$this->id.', '.$source.', "'.$this->created.'") ';
                 $cnt++;
+                if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
+                    Notice_inbox::gc($id);
+                }
                 if ($cnt >= MAX_BOXCARS) {
                     $inbox = new Notice_inbox();
                     $inbox->query($qry);
@@ -1164,6 +1183,20 @@ class Notice extends Memcached_DataObject
         }
         $tag->free();
 
+        # Enclosures
+        $attachments = $this->attachments();
+        if($attachments){
+            foreach($attachments as $attachment){
+                if ($attachment->isEnclosure()) {
+                    $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
+                    if($attachment->title){
+                        $attributes['title']=$attachment->title;
+                    }
+                    $xs->element('link', $attributes, null);
+                }
+            }
+        }
+
         $xs->elementEnd('entry');
 
         return $xs->getString();