Merge pull request #1584 from nextcloud/enh/noid/get-status-api

get status api
pull/1590/head
Maxence Lange 2023-01-18 15:18:02 -01:00 zatwierdzone przez GitHub
commit cb5283c2f7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 62 dodań i 5 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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
*

Wyświetl plik

@ -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;

Wyświetl plik

@ -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

Wyświetl plik

@ -86,6 +86,11 @@ class ExtendedQueryBuilder extends QueryBuilder implements IExtendedQueryBuilder
}
public function limitToNid(int $id): void {
$this->limitToDBFieldInt('nid', $id);
}
/**
* @param array $ids
*