summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-10-11 11:12:51 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-10-14 10:47:07 -0100
commit9e7a22348bbcccb6c50c247304c284dcbd9d31a5 (patch)
tree96cf1f4e5e229a9f0b74fa1b0fba327c78d17c2f
parentee79f483d41af19f28342d125ada74d9a2ce5a49 (diff)
new route to display remote Post: /post?id=
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--appinfo/routes.php2
-rw-r--r--lib/Controller/SocialPubController.php49
2 files changed, 50 insertions, 1 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 1474fe02..99723ce7 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -64,6 +64,8 @@ return [
['name' => 'ActivityPub#displayPost', 'url' => '/@{username}/{token}', 'verb' => 'GET'],
+ ['name' => 'SocialPub#displayRemotePost', 'url' => '/post', 'verb' => 'GET'],
+
['name' => 'Local#streamHome', 'url' => '/api/v1/stream/home', 'verb' => 'GET'],
['name' => 'Local#streamNotifications', 'url' => '/api/v1/stream/notifications', 'verb' => 'GET'],
['name' => 'Local#streamTimeline', 'url' => '/api/v1/stream/timeline', 'verb' => 'GET'],
diff --git a/lib/Controller/SocialPubController.php b/lib/Controller/SocialPubController.php
index 481bf394..c6813c2d 100644
--- a/lib/Controller/SocialPubController.php
+++ b/lib/Controller/SocialPubController.php
@@ -40,6 +40,7 @@ use OCA\Social\Exceptions\UrlCloudException;
use OCA\Social\Service\AccountService;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\ConfigService;
+use OCA\Social\Service\MiscService;
use OCA\Social\Service\StreamService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
@@ -82,6 +83,9 @@ class SocialPubController extends Controller {
/** @var ConfigService */
private $configService;
+ /** @var MiscService */
+ private $miscService;
+
/**
* SocialPubController constructor.
@@ -94,11 +98,12 @@ class SocialPubController extends Controller {
* @param AccountService $accountService
* @param StreamService $streamService
* @param ConfigService $configService
+ * @param MiscService $miscService
*/
public function __construct(
$userId, IRequest $request, IL10N $l10n, NavigationController $navigationController,
CacheActorService $cacheActorService, AccountService $accountService, StreamService $streamService,
- ConfigService $configService
+ ConfigService $configService, MiscService $miscService
) {
parent::__construct(Application::APP_NAME, $request);
@@ -109,6 +114,7 @@ class SocialPubController extends Controller {
$this->cacheActorService = $cacheActorService;
$this->streamService = $streamService;
$this->configService = $configService;
+ $this->miscService = $miscService;
}
@@ -240,5 +246,46 @@ class SocialPubController extends Controller {
}
+ /**
+ * Display the navigation page of the Social app.
+ *
+ * @NoCSRFRequired
+ * @PublicPage
+ *
+ * @param string $id
+ *
+ * @return TemplateResponse
+ * @throws SocialAppConfigException
+ * @throws StreamNotFoundException
+ */
+ public function displayRemotePost(string $id): TemplateResponse {
+ if ($id === '') {
+ throw new StreamNotFoundException('Stream not found');
+ }
+
+ if (isset($this->userId)) {
+ try {
+ $viewer = $this->accountService->getActorFromUserId($this->userId, true);
+ $this->streamService->setViewer($viewer);
+ } catch (Exception $e) {
+ }
+ }
+
+ $stream = $this->streamService->getStreamById($id, true);
+ $data = [
+ 'id' => $id,
+ 'item' => $stream,
+ 'serverData' => [
+ 'public' => ($this->userId === null),
+ ],
+ 'application' => 'Social'
+ ];
+
+ $this->miscService->log('----- ' . json_encode($data));
+
+ return new TemplateResponse(Application::APP_NAME, 'stream', $data);
+ }
+
+
}