2015-01-28 19:25:39 +00:00
|
|
|
<?php
|
2019-09-11 07:46:30 +01:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
2015-01-28 19:25:39 +00:00
|
|
|
|
2019-09-11 07:46:30 +01:00
|
|
|
defined('GNUSOCIAL') || die();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Raw public stream
|
|
|
|
*
|
|
|
|
* @category Stream
|
|
|
|
* @package GNUsocial
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
|
|
|
*/
|
2015-01-28 19:25:39 +00:00
|
|
|
|
2016-03-02 10:50:50 +00:00
|
|
|
class NetworkPublicNoticeStream extends ModeratedNoticeStream
|
2015-01-28 19:25:39 +00:00
|
|
|
{
|
2019-09-11 07:46:30 +01:00
|
|
|
public function __construct(Profile $scoped = null)
|
2015-01-28 19:25:39 +00:00
|
|
|
{
|
2019-09-11 07:46:30 +01:00
|
|
|
parent::__construct(
|
|
|
|
new CachingNoticeStream(
|
|
|
|
new RawNetworkPublicNoticeStream(),
|
|
|
|
'networkpublic'
|
|
|
|
),
|
|
|
|
$scoped
|
|
|
|
);
|
2015-01-28 19:25:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Raw public stream
|
|
|
|
*
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
2019-09-11 07:46:30 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2015-01-28 19:25:39 +00:00
|
|
|
*/
|
2020-08-09 19:00:14 +01:00
|
|
|
class RawNetworkPublicNoticeStream extends FullNoticeStream
|
2015-01-28 19:25:39 +00:00
|
|
|
{
|
2019-09-11 07:46:30 +01:00
|
|
|
public function getNoticeIds($offset, $limit, $since_id, $max_id)
|
2015-01-28 19:25:39 +00:00
|
|
|
{
|
|
|
|
$notice = new Notice();
|
|
|
|
|
|
|
|
$notice->selectAdd(); // clears it
|
|
|
|
$notice->selectAdd('id');
|
|
|
|
|
|
|
|
$notice->orderBy('created DESC, id DESC');
|
|
|
|
|
|
|
|
if (!is_null($offset)) {
|
|
|
|
$notice->limit($offset, $limit);
|
|
|
|
}
|
|
|
|
|
2019-09-11 07:46:30 +01:00
|
|
|
$notice->whereAdd('is_local = '. Notice::REMOTE);
|
2015-01-28 19:25:39 +00:00
|
|
|
// -1 == blacklisted, -2 == gateway (i.e. Twitter)
|
2019-09-11 07:46:30 +01:00
|
|
|
$notice->whereAdd('is_local <> '. Notice::LOCAL_NONPUBLIC);
|
|
|
|
$notice->whereAdd('is_local <> '. Notice::GATEWAY);
|
|
|
|
$notice->whereAdd('scope <> ' . Notice::MESSAGE_SCOPE);
|
2015-01-28 19:25:39 +00:00
|
|
|
|
|
|
|
Notice::addWhereSinceId($notice, $since_id);
|
|
|
|
Notice::addWhereMaxId($notice, $max_id);
|
|
|
|
|
2016-02-14 19:46:13 +00:00
|
|
|
self::filterVerbs($notice, $this->selectVerbs);
|
2015-01-28 19:25:39 +00:00
|
|
|
|
|
|
|
$ids = array();
|
|
|
|
|
|
|
|
if ($notice->find()) {
|
|
|
|
while ($notice->fetch()) {
|
|
|
|
$ids[] = $notice->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$notice->free();
|
2019-09-11 07:46:30 +01:00
|
|
|
$notice = null;
|
2015-01-28 19:25:39 +00:00
|
|
|
|
|
|
|
return $ids;
|
|
|
|
}
|
|
|
|
}
|