aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/PocketImport.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@smile.fr>2015-10-26 15:49:44 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:27:41 +0100
commit303768dfe9b85f87d043eb225c5c8c3a88d8c051 (patch)
tree8e29ed85236f012ac4a18b01e271a97800d98fa7 /src/Wallabag/ImportBundle/Import/PocketImport.php
parentdda57bb9443817e3a080d5d25343f5a7e15dd14f (diff)
downloadwallabag-303768dfe9b85f87d043eb225c5c8c3a88d8c051.tar.gz
wallabag-303768dfe9b85f87d043eb225c5c8c3a88d8c051.tar.zst
wallabag-303768dfe9b85f87d043eb225c5c8c3a88d8c051.zip
- remove importers configuration
- add check on userId for findOneByURL for entries
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/PocketImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 51f73f4c..dd1c34ab 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -15,19 +15,15 @@ class PocketImport implements ImportInterface
15 private $session; 15 private $session;
16 private $em; 16 private $em;
17 private $consumerKey; 17 private $consumerKey;
18 private $skippedEntries; 18 private $skippedEntries = 0;
19 private $importedEntries; 19 private $importedEntries = 0;
20 private $pocketURL;
21 20
22 public function __construct($tokenStorage, Session $session, EntityManager $em, $consumerKey, $pocketURL) 21 public function __construct($tokenStorage, Session $session, EntityManager $em, $consumerKey)
23 { 22 {
24 $this->user = $tokenStorage->getToken()->getUser(); 23 $this->user = $tokenStorage->getToken()->getUser();
25 $this->session = $session; 24 $this->session = $session;
26 $this->em = $em; 25 $this->em = $em;
27 $this->consumerKey = $consumerKey; 26 $this->consumerKey = $consumerKey;
28 $this->skippedEntries = 0;
29 $this->importedEntries = 0;
30 $this->pocketURL = $pocketURL;
31 } 27 }
32 28
33 public function getName() 29 public function getName()
@@ -121,9 +117,9 @@ class PocketImport implements ImportInterface
121 117
122 $existingEntry = $this->em 118 $existingEntry = $this->em
123 ->getRepository('WallabagCoreBundle:Entry') 119 ->getRepository('WallabagCoreBundle:Entry')
124 ->findOneByUrl($url); 120 ->findOneByUrlAndUserId($url, $this->user->getId());
125 121
126 if (!is_null($existingEntry)) { 122 if (count($existingEntry) > 0) {
127 ++$this->skippedEntries; 123 ++$this->skippedEntries;
128 continue; 124 continue;
129 } 125 }
@@ -153,7 +149,7 @@ class PocketImport implements ImportInterface
153 } 149 }
154 150
155 if (!empty($pocketEntry['tags'])) { 151 if (!empty($pocketEntry['tags'])) {
156 // $this->assignTagsToEntry($entry, $pocketEntry['tags']); 152 $this->assignTagsToEntry($entry, $pocketEntry['tags']);
157 } 153 }
158 154
159 $this->em->persist($entry); 155 $this->em->persist($entry);
@@ -166,7 +162,7 @@ class PocketImport implements ImportInterface
166 public function oAuthRequest($redirectUri, $callbackUri) 162 public function oAuthRequest($redirectUri, $callbackUri)
167 { 163 {
168 $client = $this->createClient(); 164 $client = $this->createClient();
169 $request = $client->createRequest('POST', $this->pocketURL['oauth_request'], 165 $request = $client->createRequest('POST', 'https://getpocket.com/v3/oauth/request',
170 [ 166 [
171 'body' => json_encode([ 167 'body' => json_encode([
172 'consumer_key' => $this->consumerKey, 168 'consumer_key' => $this->consumerKey,
@@ -181,14 +177,14 @@ class PocketImport implements ImportInterface
181 // store code in session for callback method 177 // store code in session for callback method
182 $this->session->set('pocketCode', $values['code']); 178 $this->session->set('pocketCode', $values['code']);
183 179
184 return $this->pocketURL['auth_authorize'].'?request_token='.$values['code'].'&redirect_uri='.$callbackUri; 180 return 'https://getpocket.com/auth/authorize?request_token='.$values['code'].'&redirect_uri='.$callbackUri;
185 } 181 }
186 182
187 public function oAuthAuthorize() 183 public function oAuthAuthorize()
188 { 184 {
189 $client = $this->createClient(); 185 $client = $this->createClient();
190 186
191 $request = $client->createRequest('POST', $this->pocketURL['oauth_authorize'], 187 $request = $client->createRequest('POST', 'https://getpocket.com/v3/oauth/authorize',
192 [ 188 [
193 'body' => json_encode([ 189 'body' => json_encode([
194 'consumer_key' => $this->consumerKey, 190 'consumer_key' => $this->consumerKey,
@@ -206,7 +202,7 @@ class PocketImport implements ImportInterface
206 { 202 {
207 $client = $this->createClient(); 203 $client = $this->createClient();
208 204
209 $request = $client->createRequest('POST', $this->pocketURL['get'], 205 $request = $client->createRequest('POST', 'https://getpocket.com/v3/get',
210 [ 206 [
211 'body' => json_encode([ 207 'body' => json_encode([
212 'consumer_key' => $this->consumerKey, 208 'consumer_key' => $this->consumerKey,