networkpublicnoticestream.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 $widgetOpts;
  29. public $scoped;
  30. public function __construct(Profile $scoped = null)
  31. {
  32. parent::__construct(
  33. new CachingNoticeStream(
  34. new RawNetworkPublicNoticeStream(),
  35. 'networkpublic'
  36. ),
  37. $scoped
  38. );
  39. }
  40. }
  41. /**
  42. * Raw public stream
  43. *
  44. * @copyright 2011 StatusNet, Inc.
  45. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  46. */
  47. class RawNetworkPublicNoticeStream extends FullNoticeStream
  48. {
  49. public function getNoticeIds($offset, $limit, $since_id, $max_id)
  50. {
  51. $notice = new Notice();
  52. $notice->selectAdd(); // clears it
  53. $notice->selectAdd('id');
  54. $notice->orderBy('created DESC, id DESC');
  55. if (!is_null($offset)) {
  56. $notice->limit($offset, $limit);
  57. }
  58. $notice->whereAdd('is_local = '. Notice::REMOTE);
  59. // -1 == blacklisted, -2 == gateway (i.e. Twitter)
  60. $notice->whereAdd('is_local <> '. Notice::LOCAL_NONPUBLIC);
  61. $notice->whereAdd('is_local <> '. Notice::GATEWAY);
  62. $notice->whereAdd('scope <> ' . Notice::MESSAGE_SCOPE);
  63. Notice::addWhereSinceId($notice, $since_id);
  64. Notice::addWhereMaxId($notice, $max_id);
  65. self::filterVerbs($notice, $this->selectVerbs);
  66. $ids = array();
  67. if ($notice->find()) {
  68. while ($notice->fetch()) {
  69. $ids[] = $notice->id;
  70. }
  71. }
  72. $notice->free();
  73. $notice = null;
  74. return $ids;
  75. }
  76. }