diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-05-31 09:31:18 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2017-06-23 10:08:54 +0200 |
commit | bf6c0346d8d35a719dd1bff1cb4d573d422f99ff (patch) | |
tree | 04fb80e20ad1cffacb72357a632a9afe2ec058cb /src/Wallabag/FederationBundle/Controller/InboxController.php | |
parent | d6d3f4ec3698effd1d4b063e295341791bdcf7d7 (diff) | |
download | wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.gz wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.zst wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.zip |
WIPfederation
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.php | 43 |
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 | |||
3 | namespace Wallabag\FederationBundle\Controller; | ||
4 | |||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
7 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
8 | use Symfony\Component\HttpFoundation\Request; | ||
9 | use Symfony\Component\HttpFoundation\Response; | ||
10 | use Wallabag\FederationBundle\Entity\Account; | ||
11 | use Wallabag\FederationBundle\Entity\Instance; | ||
12 | use Wallabag\FederationBundle\Federation\CloudId; | ||
13 | |||
14 | class 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 | } | ||