]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Fix for conversation check in @-reply notification email; i18n cleanup on mail messag...
[quix0rs-gnu-social.git] / classes / Notice.php
index 4c7e6ab4b708e7452e34dbc338fa0161cd919a83..998e9c92bad0c29dbe9b12b0f0cfebfc475aeda1 100644 (file)
@@ -119,6 +119,9 @@ class Notice extends Memcached_DataObject
         // NOTE: we don't clear queue items
 
         $result = parent::delete();
+
+        $this->blowOnDelete();
+        return $result;
     }
 
     /**
@@ -418,7 +421,21 @@ class Notice extends Memcached_DataObject
         }
 
         $profile = Profile::staticGet($this->profile_id);
-        $profile->blowNoticeCount();
+        if (!empty($profile)) {
+            $profile->blowNoticeCount();
+        }
+    }
+
+    /**
+     * Clear cache entries related to this notice at delete time.
+     * Necessary to avoid breaking paging on public, profile timelines.
+     */
+    function blowOnDelete()
+    {
+        $this->blowOnInsert();
+
+        self::blow('profile:notice_ids:%d;last', $this->profile_id);
+        self::blow('public;last');
     }
 
     /** save all urls in the notice to the db
@@ -589,7 +606,6 @@ class Notice extends Memcached_DataObject
                               array(),
                               'public',
                               $offset, $limit, $since_id, $max_id);
-
         return Notice::getStreamByIds($ids);
     }
 
@@ -683,6 +699,27 @@ class Notice extends Memcached_DataObject
         return $ids;
     }
 
+    /**
+     * Is this notice part of an active conversation?
+     * 
+     * @return boolean true if other messages exist in the same
+     *                 conversation, false if this is the only one
+     */
+    function hasConversation()
+    {
+        if (!empty($this->conversation)) {
+            $conversation = Notice::conversationStream(
+                $this->conversation,
+                1,
+                1
+            );
+            if ($conversation->N > 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * @param $groups array of Group *objects*
      * @param $recipients array of profile *ids*
@@ -948,11 +985,19 @@ class Notice extends Memcached_DataObject
      */
     function saveKnownReplies($uris)
     {
+        if (empty($uris)) {
+            return;
+        }
+        $sender = Profile::staticGet($this->profile_id);
+
         foreach ($uris as $uri) {
 
             $user = User::staticGet('uri', $uri);
 
             if (!empty($user)) {
+                if ($user->hasBlocked($sender)) {
+                    continue;
+                }
 
                 $reply = new Reply();
 
@@ -1128,6 +1173,7 @@ class Notice extends Memcached_DataObject
 
         if ($source) {
             $xs->elementStart('source');
+            $xs->element('id', null, $profile->profileurl);
             $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name'));
             $xs->element('link', array('href' => $profile->profileurl));
             $user = User::staticGet('id', $profile->id);
@@ -1143,13 +1189,14 @@ class Notice extends Memcached_DataObject
             }
 
             $xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
+            $xs->element('updated', null, common_date_w3dtf($this->created));
         }
 
         if ($source) {
             $xs->elementEnd('source');
         }
 
-        $xs->element('title', null, $this->content);
+        $xs->element('title', null, common_xml_safe_str($this->content));
 
         if ($author) {
             $xs->raw($profile->asAtomAuthor());
@@ -1225,7 +1272,11 @@ class Notice extends Memcached_DataObject
             }
         }
 
-        $xs->element('content', array('type' => 'html'), $this->rendered);
+        $xs->element(
+            'content',
+            array('type' => 'html'),
+            common_xml_safe_str($this->rendered)
+        );
 
         $tag = new Notice_tag();
         $tag->notice_id = $this->id;