kopia lustrzana https://github.com/nextcloud/social
adding liked stream
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/642/head
rodzic
ba7d78952e
commit
e1abbf1987
|
@ -66,6 +66,7 @@ return [
|
|||
['name' => 'Local#streamTag', 'url' => '/api/v1/stream/tag/{hashtag}/', 'verb' => 'GET'],
|
||||
['name' => 'Local#streamFederated', 'url' => '/api/v1/stream/federated', 'verb' => 'GET'],
|
||||
['name' => 'Local#streamDirect', 'url' => '/api/v1/stream/direct', 'verb' => 'GET'],
|
||||
['name' => 'Local#streamLiked', 'url' => '/api/v1/stream/liked', 'verb' => 'GET'],
|
||||
['name' => 'Local#streamAccount', 'url' => '/api/v1/account/{username}/stream', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#postCreate', 'url' => '/api/v1/post', 'verb' => 'POST'],
|
||||
|
|
|
@ -467,6 +467,28 @@ class LocalController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get liked post
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamLiked(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamLiked($since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
|
|
|
@ -1100,6 +1100,6 @@ class CoreRequestBuilder {
|
|||
$qb->where($this->exprLimitToDBField($qb, 'class', 'OCA\Social\Cron\Queue', true, true));
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -483,10 +483,7 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
$qb = $this->getStreamSelectSql();
|
||||
$this->limitPaginate($qb, $since, $limit);
|
||||
|
||||
// if ($localOnly) {
|
||||
$this->limitToLocal($qb, $localOnly);
|
||||
// }
|
||||
|
||||
$this->limitToType($qb, Note::TYPE);
|
||||
|
||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
|
@ -509,6 +506,40 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should returns:
|
||||
* * All liked posts
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
* @param bool $localOnly
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getLiked(int $since = 0, int $limit = 5, bool $localOnly = true): array {
|
||||
$qb = $this->getStreamSelectSql();
|
||||
$this->limitPaginate($qb, $since, $limit);
|
||||
|
||||
$this->limitToType($qb, Note::TYPE);
|
||||
|
||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
$this->leftJoinStreamAction($qb);
|
||||
|
||||
$streams = [];
|
||||
$cursor = $qb->execute();
|
||||
while ($data = $cursor->fetch()) {
|
||||
try {
|
||||
// $streams[] = $this->parseStreamSelectSql($data);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
}
|
||||
$cursor->closeCursor();
|
||||
|
||||
return $streams;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should returns:
|
||||
* - All public post related to a tag (not yet)
|
||||
|
|
|
@ -442,7 +442,7 @@ class NoteService {
|
|||
}
|
||||
|
||||
|
||||
/**m
|
||||
/**
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
|
@ -455,6 +455,19 @@ class NoteService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Note[]
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getStreamLiked(int $since = 0, int $limit = 5): array {
|
||||
return $this->streamRequest->getLiked($since, $limit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $noteId
|
||||
*
|
||||
|
|
Ładowanie…
Reference in New Issue