123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- defined('GNUSOCIAL') || die();
- abstract class NoticeStream
- {
- protected $selectVerbs = [
- ActivityVerb::POST => true,
- ActivityVerb::SHARE => true,
- ];
- public function __construct()
- {
- foreach ($this->selectVerbs as $key => $val) {
- $this->selectVerbs[ActivityUtils::resolveUri($key)] = $val;
-
-
- }
- }
- abstract public function getNoticeIds($offset, $limit, $since_id, $max_id);
- public function getNotices($offset, $limit, $sinceId = null, $maxId = null)
- {
- $ids = $this->getNoticeIds($offset, $limit, $sinceId, $maxId);
- return self::getStreamByIds($ids);
- }
- public static function getStreamByIds($ids)
- {
- return Notice::multiGet('id', $ids);
- }
- public static function filterVerbs(Notice $notice, array $selectVerbs)
- {
- $filter = array_keys(array_filter($selectVerbs));
- if (!empty($filter)) {
-
- $notice->whereAddIn('verb', $filter, $notice->columnType('verb'));
- }
- $filter = array_keys(array_filter($selectVerbs, function ($v) {
- return !$v;
- }));
- if (!empty($filter)) {
-
- $notice->whereAddIn('!verb', $filter, $notice->columnType('verb'));
- }
- unset($filter);
- }
- }
|