From 06fb856d24bf1238c281360b6003ba4e708daa34 Mon Sep 17 00:00:00 2001 From: tenma Date: Mon, 19 Aug 2019 22:41:03 +0100 Subject: [PATCH] [CORE] Add new Notice scope for private messaging Notice: - Add MESSAGE_SCOPE scope lib/*.stream: - Filter out notices with MESSAGE_SCOPE scope --- classes/Notice.php | 3 ++- lib/inboxnoticestream.php | 2 ++ lib/networkpublicnoticestream.php | 1 + lib/profilenoticestream.php | 2 ++ lib/publicnoticestream.php | 1 + lib/replynoticestream.php | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/classes/Notice.php b/classes/Notice.php index 56e35fd17d..4c8d0d1d88 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -93,7 +93,7 @@ class Notice extends Managed_DataObject 'object_type' => array('type' => 'varchar', 'length' => 191, 'description' => 'URI representing activity streams object type', 'default' => null), 'verb' => array('type' => 'varchar', 'length' => 191, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'), 'scope' => array('type' => 'int', - 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers; null = default'), + 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = followers; 16 = messages; null = default'), ), 'primary key' => array('id'), 'unique keys' => array( @@ -136,6 +136,7 @@ class Notice extends Managed_DataObject const ADDRESSEE_SCOPE = 2; const GROUP_SCOPE = 4; const FOLLOWER_SCOPE = 8; + const MESSAGE_SCOPE = 16; protected $_profile = array(); diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php index c8b5ccd7af..d99e427efc 100644 --- a/lib/inboxnoticestream.php +++ b/lib/inboxnoticestream.php @@ -127,6 +127,8 @@ class RawInboxNoticeStream extends FullNoticeStream $notice->whereAdd(sprintf('notice.id <= %d', $max_id)); } + $notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE); + self::filterVerbs($notice, $this->selectVerbs); $notice->limit($offset, $limit); diff --git a/lib/networkpublicnoticestream.php b/lib/networkpublicnoticestream.php index c722bd8c14..b77f879dc8 100644 --- a/lib/networkpublicnoticestream.php +++ b/lib/networkpublicnoticestream.php @@ -42,6 +42,7 @@ class RawNetworkPublicNoticeStream extends FullNoticeStream // -1 == blacklisted, -2 == gateway (i.e. Twitter) $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC); $notice->whereAdd('is_local !='. Notice::GATEWAY); + $notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE); Notice::addWhereSinceId($notice, $since_id); Notice::addWhereMaxId($notice, $max_id); diff --git a/lib/profilenoticestream.php b/lib/profilenoticestream.php index bfe49efea5..91eef03cc9 100644 --- a/lib/profilenoticestream.php +++ b/lib/profilenoticestream.php @@ -127,6 +127,8 @@ class RawProfileNoticeStream extends NoticeStream $notice->selectAdd(); $notice->selectAdd('id'); + $notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE); + Notice::addWhereSinceId($notice, $since_id); Notice::addWhereMaxId($notice, $max_id); diff --git a/lib/publicnoticestream.php b/lib/publicnoticestream.php index 2638292714..158fd1a839 100644 --- a/lib/publicnoticestream.php +++ b/lib/publicnoticestream.php @@ -79,6 +79,7 @@ class RawPublicNoticeStream extends FullNoticeStream // This feed always gives only local activities. $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC); + $notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE); Notice::addWhereSinceId($notice, $since_id); Notice::addWhereMaxId($notice, $max_id); diff --git a/lib/replynoticestream.php b/lib/replynoticestream.php index d6b2882193..3bc192d330 100644 --- a/lib/replynoticestream.php +++ b/lib/replynoticestream.php @@ -101,6 +101,8 @@ class RawReplyNoticeStream extends NoticeStream } } + $reply->whereAdd('notice.scope != ' . NOTICE::MESSAGE_SCOPE); + $reply->orderBy('reply.modified DESC, reply.notice_id DESC'); if (!is_null($offset)) {