2011-03-24 22:04:19 +00:00
|
|
|
<?php
|
2020-08-27 09:15:39 +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/>.
|
|
|
|
|
2011-03-25 16:22:22 +00:00
|
|
|
/**
|
|
|
|
* Stream of notices that are repeats of mine
|
|
|
|
*
|
|
|
|
* @category Stream
|
2020-08-27 09:15:39 +01:00
|
|
|
* @package GNUsocial
|
2011-03-25 16:22:22 +00:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
2020-08-27 09:15:39 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2011-03-25 16:22:22 +00:00
|
|
|
*/
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
defined('GNUSOCIAL') || die();
|
2011-03-25 16:22:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stream of notices that are repeats of mine
|
|
|
|
*
|
|
|
|
* @category Stream
|
2020-08-27 09:15:39 +01:00
|
|
|
* @package GNUsocial
|
2011-03-25 16:22:22 +00:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
2020-08-27 09:15:39 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2011-03-25 16:22:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
class RepeatsOfMeNoticeStream extends ScopingNoticeStream
|
2011-03-24 22:04:19 +00:00
|
|
|
{
|
2020-08-27 09:15:39 +01:00
|
|
|
public function __construct(Profile $target, Profile $scoped=null)
|
2011-03-24 22:04:19 +00:00
|
|
|
{
|
2020-08-27 09:15:39 +01:00
|
|
|
parent::__construct(new CachingNoticeStream(
|
|
|
|
new RawRepeatsOfMeNoticeStream($target),
|
|
|
|
'user:repeats_of_me:' . $target->getID()
|
|
|
|
), $scoped);
|
2011-03-24 22:04:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-25 16:22:22 +00:00
|
|
|
/**
|
|
|
|
* Raw stream of notices that are repeats of mine
|
|
|
|
*
|
|
|
|
* @category Stream
|
2020-08-27 09:15:39 +01:00
|
|
|
* @package GNUsocial
|
2011-03-25 16:22:22 +00:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
2020-08-27 09:15:39 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2011-03-25 16:22:22 +00:00
|
|
|
*/
|
2011-03-24 22:04:19 +00:00
|
|
|
class RawRepeatsOfMeNoticeStream extends NoticeStream
|
|
|
|
{
|
2016-03-01 13:51:47 +00:00
|
|
|
protected $target;
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
public function __construct(Profile $target)
|
2011-03-24 22:04:19 +00:00
|
|
|
{
|
2016-03-01 13:51:47 +00:00
|
|
|
$this->target = $target;
|
2011-03-24 22:04:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
public function getNoticeIds($offset, $limit, $since_id, $max_id)
|
2011-03-24 22:04:19 +00:00
|
|
|
{
|
2020-08-27 09:15:39 +01:00
|
|
|
$notice = new Notice();
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
$notice->selectAdd();
|
|
|
|
$notice->selectAdd('notice.id');
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
$notice->joinAdd(['id', 'notice:repeat_of'], 'LEFT', 'repeat');
|
|
|
|
$notice->whereAdd('repeat.repeat_of IS NOT NULL');
|
|
|
|
$notice->whereAdd('notice.profile_id = ' . $this->target->getID());
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
Notice::addWhereSinceId($notice, $since_id);
|
|
|
|
Notice::addWhereMaxId($notice, $max_id);
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
$notice->orderBy('notice.created DESC, notice.id DESC');
|
|
|
|
$notice->limit($offset, $limit);
|
2011-03-24 22:04:19 +00:00
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
if (!$notice->find()) {
|
|
|
|
return [];
|
2011-03-24 22:04:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-27 09:15:39 +01:00
|
|
|
return $notice->fetchAll('id');
|
2011-03-24 22:04:19 +00:00
|
|
|
}
|
|
|
|
}
|