networkpublicnoticestream.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. defined('GNUSOCIAL') || die();
  17. /**
  18. * Raw public stream
  19. *
  20. * @category Stream
  21. * @package GNUsocial
  22. * @author Evan Prodromou <evan@status.net>
  23. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  24. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  25. */
  26. class NetworkPublicNoticeStream extends ModeratedNoticeStream
  27. {
  28. public function __construct(Profile $scoped = null)
  29. {
  30. parent::__construct(
  31. new CachingNoticeStream(
  32. new RawNetworkPublicNoticeStream(),
  33. 'networkpublic'
  34. ),
  35. $scoped
  36. );
  37. }
  38. }
  39. /**
  40. * Raw public stream
  41. *
  42. * @copyright 2011 StatusNet, Inc.
  43. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  44. */
  45. class RawNetworkPublicNoticeStream extends FullNoticeStream
  46. {
  47. public function getNoticeIds($offset, $limit, $since_id, $max_id)
  48. {
  49. $notice = new Notice();
  50. $notice->selectAdd(); // clears it
  51. $notice->selectAdd('id');
  52. $notice->orderBy('created DESC, id DESC');
  53. if (!is_null($offset)) {
  54. $notice->limit($offset, $limit);
  55. }
  56. $notice->whereAdd('is_local = '. Notice::REMOTE);
  57. // -1 == blacklisted, -2 == gateway (i.e. Twitter)
  58. $notice->whereAdd('is_local <> '. Notice::LOCAL_NONPUBLIC);
  59. $notice->whereAdd('is_local <> '. Notice::GATEWAY);
  60. $notice->whereAdd('scope <> ' . Notice::MESSAGE_SCOPE);
  61. Notice::addWhereSinceId($notice, $since_id);
  62. Notice::addWhereMaxId($notice, $max_id);
  63. self::filterVerbs($notice, $this->selectVerbs);
  64. $ids = array();
  65. if ($notice->find()) {
  66. while ($notice->fetch()) {
  67. $ids[] = $notice->id;
  68. }
  69. }
  70. $notice->free();
  71. $notice = null;
  72. return $ids;
  73. }
  74. }