mirror of
https://github.com/flarum/core.git
synced 2025-10-18 10:16:09 +02:00
Add user activity system
This commit is contained in:
30
src/Api/Actions/Posts/GetsPosts.php
Normal file
30
src/Api/Actions/Posts/GetsPosts.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
|
||||
trait GetsPosts
|
||||
{
|
||||
protected function getPosts(ApiParams $params, $where)
|
||||
{
|
||||
$sort = $params->sort(['time']);
|
||||
$count = $params->count(20, 50);
|
||||
$user = $this->actor->getUser();
|
||||
|
||||
if (isset($where['discussion_id']) && ($near = $params->get('near')) > 1) {
|
||||
$start = $this->posts->getIndexForNumber($where['discussion_id'], $near, $user);
|
||||
$start = max(0, $start - $count / 2);
|
||||
} else {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
return $this->posts->findWhere(
|
||||
$where,
|
||||
$user,
|
||||
$sort['field'],
|
||||
$sort['order'] ?: 'asc',
|
||||
$count,
|
||||
$start
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user