aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/FederationBundle/Controller/InboxController.php
diff options
context:
space:
mode:
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}