[CORE] Add new Notice scope for private messaging

Notice:
- Add MESSAGE_SCOPE scope

lib/*.stream:
- Filter out notices with MESSAGE_SCOPE scope
This commit is contained in:
tenma 2019-08-19 22:41:03 +01:00 committed by Diogo Cordeiro
parent 2519431f02
commit c802480d75
6 changed files with 10 additions and 1 deletions

View File

@ -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), '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'), 'verb' => array('type' => 'varchar', 'length' => 191, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'),
'scope' => array('type' => 'int', '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'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -136,6 +136,7 @@ class Notice extends Managed_DataObject
const ADDRESSEE_SCOPE = 2; const ADDRESSEE_SCOPE = 2;
const GROUP_SCOPE = 4; const GROUP_SCOPE = 4;
const FOLLOWER_SCOPE = 8; const FOLLOWER_SCOPE = 8;
const MESSAGE_SCOPE = 16;
protected $_profile = array(); protected $_profile = array();

View File

@ -127,6 +127,8 @@ class RawInboxNoticeStream extends FullNoticeStream
$notice->whereAdd(sprintf('notice.id <= %d', $max_id)); $notice->whereAdd(sprintf('notice.id <= %d', $max_id));
} }
$notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE);
self::filterVerbs($notice, $this->selectVerbs); self::filterVerbs($notice, $this->selectVerbs);
$notice->limit($offset, $limit); $notice->limit($offset, $limit);

View File

@ -42,6 +42,7 @@ class RawNetworkPublicNoticeStream extends FullNoticeStream
// -1 == blacklisted, -2 == gateway (i.e. Twitter) // -1 == blacklisted, -2 == gateway (i.e. Twitter)
$notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC); $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !='. Notice::GATEWAY); $notice->whereAdd('is_local !='. Notice::GATEWAY);
$notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE);
Notice::addWhereSinceId($notice, $since_id); Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id); Notice::addWhereMaxId($notice, $max_id);

View File

@ -127,6 +127,8 @@ class RawProfileNoticeStream extends NoticeStream
$notice->selectAdd(); $notice->selectAdd();
$notice->selectAdd('id'); $notice->selectAdd('id');
$notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE);
Notice::addWhereSinceId($notice, $since_id); Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id); Notice::addWhereMaxId($notice, $max_id);

View File

@ -79,6 +79,7 @@ class RawPublicNoticeStream extends FullNoticeStream
// This feed always gives only local activities. // This feed always gives only local activities.
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC); $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
$notice->whereAdd('scope != ' . Notice::MESSAGE_SCOPE);
Notice::addWhereSinceId($notice, $since_id); Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id); Notice::addWhereMaxId($notice, $max_id);

View File

@ -101,6 +101,8 @@ class RawReplyNoticeStream extends NoticeStream
} }
} }
$reply->whereAdd('notice.scope != ' . NOTICE::MESSAGE_SCOPE);
$reply->orderBy('reply.modified DESC, reply.notice_id DESC'); $reply->orderBy('reply.modified DESC, reply.notice_id DESC');
if (!is_null($offset)) { if (!is_null($offset)) {