aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/FederationBundle/Controller/InboxController.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-05-31 09:31:18 +0200
committerThomas Citharel <tcit@tcit.fr>2017-06-23 10:08:54 +0200
commitbf6c0346d8d35a719dd1bff1cb4d573d422f99ff (patch)
tree04fb80e20ad1cffacb72357a632a9afe2ec058cb /src/Wallabag/FederationBundle/Controller/InboxController.php
parentd6d3f4ec3698effd1d4b063e295341791bdcf7d7 (diff)
downloadwallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.gz
wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.zst
wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.zip
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'src/Wallabag/FederationBundle/Controller/InboxController.php')
-rw-r--r--src/Wallabag/FederationBundle/Controller/InboxController.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Wallabag/FederationBundle/Controller/InboxController.php b/src/Wallabag/FederationBundle/Controller/InboxController.php
new file mode 100644
index 00000000..99cfeadf
--- /dev/null
+++ b/src/Wallabag/FederationBundle/Controller/InboxController.php
@@ -0,0 +1,43 @@
1<?php
2
3namespace Wallabag\FederationBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\HttpFoundation\Response;
10use Wallabag\FederationBundle\Entity\Account;
11use Wallabag\FederationBundle\Entity\Instance;
12use Wallabag\FederationBundle\Federation\CloudId;
13
14class InboxController extends Controller
15{
16 /**
17 * @Route("/profile/inbox", name="user-inbox")
18 *
19 * @param Request $request
20 * @return Response
21 */
22 public function userInboxAction(Request $request)
23 {
24 $em = $this->getDoctrine()->getManager();
25 $response = new Response();
26
27 if ($activity = json_decode($request->getContent())) {
28 if ($activity->type === 'Follow' && isset($activity->actor->id)) {
29 $cloudId = new CloudId($activity->actor->id);
30 $account = new Account();
31 $account->setServer($cloudId->getRemote())
32 ->setUsername($cloudId->getUser());
33 $em->persist($account);
34 $em->flush();
35
36 $response->setStatusCode(201);
37 } else {
38 $response->setStatusCode(400);
39 }
40 }
41 return $response;
42 }
43}