kopia lustrzana https://github.com/nextcloud/social
get status api
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/1584/head
rodzic
f72667819e
commit
fa27422740
appinfo
lib
Controller
Service
Tools/Db
|
@ -79,11 +79,12 @@ return [
|
|||
['name' => 'Api#instance', 'url' => '/api/v1/instance/', 'verb' => 'GET'],
|
||||
['name' => 'Api#customEmojis', 'url' => '/api/v1/custom_emojis', 'verb' => 'GET'],
|
||||
['name' => 'Api#savedSearches', 'url' => '/api/saved_searches/list.json', 'verb' => 'GET'],
|
||||
['name' => 'Api#timelines', 'url' => '/api/v1/timelines/{timeline}/', 'verb' => 'GET'],
|
||||
['name' => 'Api#favourites', 'url' => '/api/v1/favourites/', 'verb' => 'GET'],
|
||||
['name' => 'Api#notifications', 'url' => '/api/v1/notifications', 'verb' => 'GET'],
|
||||
['name' => 'Api#tag', 'url' => '/api/v1/timelines/tag/{hashtag}', 'verb' => 'GET'],
|
||||
['name' => 'Api#statusNew', 'url' => '/api/v1/statuses', 'verb' => 'POST'],
|
||||
['name' => 'Api#timelines', 'url' => '/api/v1/timelines/{timeline}/', 'verb' => 'GET'],
|
||||
['name' => 'Api#statusGet', 'url' => '/api/v1/statuses/{nid}', 'verb' => 'GET'],
|
||||
['name' => 'Api#accountStatuses', 'url' => '/api/v1/accounts/{account}/statuses', 'verb' => 'GET'],
|
||||
|
||||
// Api for local front-end
|
||||
|
|
|
@ -281,6 +281,28 @@ class ApiController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param int $nid
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function statusGet(int $nid): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
|
||||
$item = $this->streamService->getStreamByNid($nid);
|
||||
|
||||
return new DataResponse($item, Http::STATUS_OK);
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
|
|
|
@ -227,6 +227,26 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param bool $asViewer
|
||||
* @param int $format
|
||||
*
|
||||
* @return Stream
|
||||
* @throws StreamNotFoundException
|
||||
*/
|
||||
public function getStreamByNid(int $nid): Stream {
|
||||
$qb = $this->getStreamSelectSql(ACore::FORMAT_LOCAL);
|
||||
$qb->limitToNid($nid);
|
||||
$qb->linkToCacheActors('ca', 's.attributed_to_prim');
|
||||
|
||||
$qb->limitToViewer('sd', 'f', true, true);
|
||||
$qb->leftJoinStreamAction('sa');
|
||||
|
||||
return $this->getStreamFromRequest($qb);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $idPrim
|
||||
*
|
||||
|
@ -446,8 +466,6 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Should returns:
|
||||
* - public message from actorId.
|
||||
|
@ -482,7 +500,6 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param TimelineOptions $options
|
||||
*
|
||||
|
|
|
@ -172,7 +172,7 @@ class StreamRequestBuilder extends CoreRequestBuilder {
|
|||
try {
|
||||
$result = $qb->getRow([$this, 'parseStreamSelectSql']);
|
||||
} catch (RowNotFoundException $e) {
|
||||
throw new StreamNotFoundException($e->getMessage());
|
||||
throw new StreamNotFoundException('stream not found');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -358,6 +358,18 @@ class StreamService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param bool $asViewer
|
||||
*
|
||||
* @return Stream
|
||||
* @throws StreamNotFoundException
|
||||
*/
|
||||
public function getStreamByNid(int $nid): Stream {
|
||||
return $this->streamRequest->getStreamByNid($nid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param int $since
|
||||
|
|
|
@ -86,6 +86,11 @@ class ExtendedQueryBuilder extends QueryBuilder implements IExtendedQueryBuilder
|
|||
}
|
||||
|
||||
|
||||
public function limitToNid(int $id): void {
|
||||
$this->limitToDBFieldInt('nid', $id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
*
|
||||
|
|
Ładowanie…
Reference in New Issue