]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
NoticeStream fixes regarding non-post verbs
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 13 Jul 2014 22:59:04 +0000 (00:59 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 13 Jul 2014 22:59:04 +0000 (00:59 +0200)
lib/conversationnoticestream.php
lib/inboxnoticestream.php
lib/noticestream.php
lib/profilenoticestream.php
lib/publicnoticestream.php
plugins/Favorite/lib/favenoticestream.php

index 21b942c018fc3ab74d7a2a61f93a9ac885459f8c..27489a42dfe777be9017c4f53d142fdbbbfbb158 100644 (file)
@@ -95,10 +95,8 @@ class RawConversationNoticeStream extends NoticeStream
             $notice->limit($offset, $limit);
         }
 
-        if (!$this->allVerbs) {
-            $notice->whereAdd(sprintf('verb="%s" OR verb="%s"',
-                                      ActivityVerb::POST,
-                                      ActivityUtils::resolveUri(ActivityVerb::POST, true)));
+        if (!empty($this->selectVerbs)) {
+            $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
         }
 
         // ORDER BY
index eacbb771277138ebe83edfb42fbc0078ba0a15e0..87868b1d79aab4f2e6b852dac3a7106ac229c293 100644 (file)
@@ -118,6 +118,9 @@ class RawInboxNoticeStream extends NoticeStream
         if (!empty($max_id)) {
             $notice->whereAdd(sprintf('notice.id <= %d', $max_id));
         }
+        if (!empty($this->selectVerbs)) {
+            $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
+        }
         $notice->limit($offset, $limit);
         // notice.id will give us even really old posts, which were
         // recently imported. For example if a remote instance had
index c072941a693e78b7435d09f01a295f6de7f12271..0f53daf83f407e15a878d747d1268b972eb451c9 100644 (file)
@@ -46,7 +46,13 @@ if (!defined('STATUSNET')) {
  */
 abstract class NoticeStream
 {
-    protected $allVerbs = false;    // Will only get 'post' activityverbs by default.
+    // Will only get notices with the 'post' activityverb by default.
+    protected $selectVerbs = array();
+
+    public function __construct()
+    {
+        $this->selectVerbs = array(ActivityVerb::POST, ActivityUtils::resolveUri(ActivityVerb::POST, true));
+    }
 
     abstract function getNoticeIds($offset, $limit, $since_id, $max_id);
 
index a59a5d848b8ce06429e2a173e1b48a66260ea919..1fa795d32090a55866c49f9221757ab7c089fdcb 100644 (file)
@@ -121,6 +121,7 @@ class RawProfileNoticeStream extends NoticeStream
 
     function __construct($profile)
     {
+        parent::__construct();
         $this->profile = $profile;
     }
 
@@ -136,12 +137,6 @@ class RawProfileNoticeStream extends NoticeStream
         Notice::addWhereSinceId($notice, $since_id);
         Notice::addWhereMaxId($notice, $max_id);
 
-        if (!$this->allVerbs) {
-            $notice->whereAdd(sprintf('verb="%s" OR verb="%s"',
-                                      ActivityVerb::POST,
-                                      ActivityUtils::resolveUri(ActivityVerb::POST, true)));
-        }
-
         $notice->orderBy('created DESC, id DESC');
 
         if (!is_null($offset)) {
index 222eead0efb1c940db610388f5392c0684763d45..34f7b4a1defb69d558bd6949118496cff3aa147f 100644 (file)
@@ -92,10 +92,8 @@ class RawPublicNoticeStream extends NoticeStream
         Notice::addWhereSinceId($notice, $since_id);
         Notice::addWhereMaxId($notice, $max_id);
 
-        if (!$this->allVerbs) {
-            $notice->whereAdd(sprintf('verb="%s" OR verb="%s"',
-                                      ActivityVerb::POST,
-                                      ActivityUtils::resolveUri(ActivityVerb::POST, true)));
+        if (!empty($this->selectVerbs)) {
+            $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
         }
 
         $ids = array();
index 6527e5441e37cc8dd5c11acb9bd1e6f93b1c8c4c..6294c8cdda44f9d7378ae8cbe5f34bdeebd14af4 100644 (file)
@@ -79,8 +79,12 @@ class RawFaveNoticeStream extends NoticeStream
 
     function __construct($user_id, $own)
     {
+        parent::__construct();
+
         $this->user_id = $user_id;
         $this->own     = $own;
+
+        $this->selectVerbs = array();
     }
 
     /**