From efa3e8f3f4001ee01771a8bb69312cfcc5565c79 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 9 Jul 2014 13:37:09 +0200 Subject: [PATCH] Only get POST verbs for noticestreams for now Since we store 'favorite' verbs as notices now too, they caused a lot of "null" notices that might not be interesting before we handle them better in the UIs. --- lib/conversationnoticestream.php | 6 ++++++ lib/noticestream.php | 2 ++ lib/profilenoticestream.php | 6 ++++++ lib/publicnoticestream.php | 8 +++++++- lib/replynoticestream.php | 8 +++++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/conversationnoticestream.php b/lib/conversationnoticestream.php index b9b03c45c5..21b942c018 100644 --- a/lib/conversationnoticestream.php +++ b/lib/conversationnoticestream.php @@ -95,6 +95,12 @@ 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))); + } + // ORDER BY // currently imitates the previously used "_reverseChron" sorting $notice->orderBy('notice.created DESC'); diff --git a/lib/noticestream.php b/lib/noticestream.php index e9ff47b68c..c072941a69 100644 --- a/lib/noticestream.php +++ b/lib/noticestream.php @@ -46,6 +46,8 @@ if (!defined('STATUSNET')) { */ abstract class NoticeStream { + protected $allVerbs = false; // Will only get 'post' activityverbs by default. + abstract function getNoticeIds($offset, $limit, $since_id, $max_id); function getNotices($offset, $limit, $sinceId = null, $maxId = null) diff --git a/lib/profilenoticestream.php b/lib/profilenoticestream.php index ac18e1c8cd..a59a5d848b 100644 --- a/lib/profilenoticestream.php +++ b/lib/profilenoticestream.php @@ -136,6 +136,12 @@ 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)) { diff --git a/lib/publicnoticestream.php b/lib/publicnoticestream.php index 044701aaf6..222eead0ef 100644 --- a/lib/publicnoticestream.php +++ b/lib/publicnoticestream.php @@ -92,6 +92,12 @@ 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))); + } + $ids = array(); if ($notice->find()) { @@ -105,4 +111,4 @@ class RawPublicNoticeStream extends NoticeStream return $ids; } -} \ No newline at end of file +} diff --git a/lib/replynoticestream.php b/lib/replynoticestream.php index ec13ff9a67..b5f0621a9e 100644 --- a/lib/replynoticestream.php +++ b/lib/replynoticestream.php @@ -86,6 +86,12 @@ class RawReplyNoticeStream extends NoticeStream Notice::addWhereSinceId($reply, $since_id, 'notice_id', 'modified'); Notice::addWhereMaxId($reply, $max_id, 'notice_id', 'modified'); + if (!$this->allVerbs) { + $notice->whereAdd(sprintf('verb="%s" OR verb="%s"', + ActivityVerb::POST, + ActivityUtils::resolveUri(ActivityVerb::POST, true))); + } + $reply->orderBy('modified DESC, notice_id DESC'); if (!is_null($offset)) { @@ -102,4 +108,4 @@ class RawReplyNoticeStream extends NoticeStream return $ids; } -} \ No newline at end of file +}