kopia lustrzana https://github.com/nextcloud/social
display single note
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/730/head
rodzic
d234063bfa
commit
7b2834acc9
|
@ -60,7 +60,7 @@ return [
|
|||
['name' => 'OStatus#followRemote', 'url' => '/api/v1/ostatus/followRemote/{local}', 'verb' => 'GET'],
|
||||
['name' => 'OStatus#getLink', 'url' => '/api/v1/ostatus/link/{local}/{account}', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'SocialPub#displayPost', 'url' => '/@{username}/{postId}', 'verb' => 'GET'],
|
||||
['name' => 'SocialPub#displayPost', 'url' => '/@{username}/{token}', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#streamHome', 'url' => '/api/v1/stream/home', 'verb' => 'GET'],
|
||||
['name' => 'Local#streamNotifications', 'url' => '/api/v1/stream/notifications', 'verb' => 'GET'],
|
||||
|
@ -71,8 +71,7 @@ return [
|
|||
['name' => 'Local#streamLiked', 'url' => '/api/v1/stream/liked', 'verb' => 'GET'],
|
||||
['name' => 'Local#streamAccount', 'url' => '/api/v1/account/{username}/stream', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#postData', 'url' => '/local/v1/post', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#postGet', 'url' => '/local/v1/post', 'verb' => 'GET'],
|
||||
['name' => 'Local#postCreate', 'url' => '/api/v1/post', 'verb' => 'POST'],
|
||||
['name' => 'Local#postDelete', 'url' => '/api/v1/post', 'verb' => 'DELETE'],
|
||||
|
||||
|
|
|
@ -194,16 +194,19 @@ class LocalController extends Controller {
|
|||
* get info about a post (limited to viewer rights).
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $postId
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postData(string $id): DataResponse {
|
||||
public function postGet(string $postId): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
|
||||
return $this->directSuccess($this->streamService->getStreamById($id, true));
|
||||
$stream = $this->streamService->getStreamById($postId, true);
|
||||
|
||||
return $this->directSuccess($stream);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
|
|
|
@ -31,14 +31,15 @@ namespace OCA\Social\Controller;
|
|||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
|
||||
use Exception;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Service\AccountService;
|
||||
use OCA\Social\Service\CacheActorService;
|
||||
use OCA\Social\Service\FollowService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\StreamService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
|
@ -52,23 +53,24 @@ class SocialPubController extends Controller {
|
|||
|
||||
use TNCDataResponse;
|
||||
|
||||
|
||||
/** @var string */
|
||||
private $userId;
|
||||
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
|
||||
/** @var AccountService */
|
||||
private $accountService;
|
||||
/** @var NavigationController */
|
||||
private $navigationController;
|
||||
|
||||
/** @var CacheActorService */
|
||||
private $cacheActorService;
|
||||
|
||||
/** @var FollowService */
|
||||
private $followService;
|
||||
/** @var StreamService */
|
||||
private $streamService;
|
||||
|
||||
/** @var NavigationController */
|
||||
private $navigationController;
|
||||
/** @var ConfigService */
|
||||
private $configService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -77,36 +79,39 @@ class SocialPubController extends Controller {
|
|||
* @param $userId
|
||||
* @param IRequest $request
|
||||
* @param IL10N $l10n
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param NavigationController $navigationController
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param StreamService $streamService
|
||||
* @param ConfigService $configService
|
||||
*/
|
||||
public function __construct(
|
||||
$userId,
|
||||
IRequest $request,
|
||||
IL10N $l10n,
|
||||
CacheActorService $cacheActorService,
|
||||
NavigationController $navigationController
|
||||
$userId, IRequest $request, IL10N $l10n, NavigationController $navigationController,
|
||||
CacheActorService $cacheActorService, StreamService $streamService, ConfigService $configService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
|
||||
$this->userId = $userId;
|
||||
$this->l10n = $l10n;
|
||||
$this->cacheActorService = $cacheActorService;
|
||||
$this->navigationController = $navigationController;
|
||||
$this->cacheActorService = $cacheActorService;
|
||||
$this->streamService = $streamService;
|
||||
$this->configService = $configService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $username
|
||||
*
|
||||
* @return Response
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
private function renderPage($username): Response {
|
||||
if ($this->userId) {
|
||||
return $this->navigationController->navigate('');
|
||||
}
|
||||
$data = [
|
||||
'serverData' => [
|
||||
'serverData' => [
|
||||
'public' => true,
|
||||
],
|
||||
'application' => 'Social'
|
||||
|
@ -141,6 +146,7 @@ class SocialPubController extends Controller {
|
|||
*
|
||||
* @return Response
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function actor(string $username): Response {
|
||||
return $this->renderPage($username);
|
||||
|
@ -158,6 +164,7 @@ class SocialPubController extends Controller {
|
|||
*
|
||||
* @return TemplateResponse
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function followers(string $username): Response {
|
||||
return $this->renderPage($username);
|
||||
|
@ -175,6 +182,7 @@ class SocialPubController extends Controller {
|
|||
*
|
||||
* @return TemplateResponse
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function following(string $username): Response {
|
||||
return $this->renderPage($username);
|
||||
|
@ -182,19 +190,30 @@ class SocialPubController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* Should return post, do nothing.
|
||||
* Display the navigation page of the Social app.
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $username
|
||||
* @param $postId
|
||||
* @param string $token
|
||||
*
|
||||
* @return Response
|
||||
* @return TemplateResponse
|
||||
* @throws StreamNotFoundException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function displayPost(string $username, int $postId) {
|
||||
return $this->success([$username, $postId]);
|
||||
public function displayPost(string $username, string $token): TemplateResponse {
|
||||
// TODO - check viewer rights !
|
||||
$postId = $this->configService->getSocialUrl() . '@' . $username . '/' . $token;
|
||||
$stream = $this->streamService->getStreamById($postId, false);
|
||||
$data = [
|
||||
'id' => $postId,
|
||||
'item' => $stream
|
||||
];
|
||||
|
||||
return new TemplateResponse(Application::APP_NAME, 'stream', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<pre>
|
||||
<?php p($_['id']); ?>
|
||||
</pre>
|
||||
<br />
|
||||
<br />
|
||||
<pre>
|
||||
<?php p(json_encode($_['item'], JSON_PRETTY_PRINT)); ?>
|
||||
</pre>
|
Ładowanie…
Reference in New Issue