Commit graph

85 commits

Author SHA1 Message Date
Jeremy Benoist 6aca334d53
Move to controller as a service
Mostly using autowiring to inject deps.
The only tricky part was for import because all producer use the same class and have a different alias. So we must write them down in the service definition, autowiring doesn't work in that case.

Usually:
- if a controller has a constructor, it means injected services are at least re-used once in actions
- otherwise, service are injected per action
2022-12-19 10:38:08 +01:00
Jeremy Benoist d47c208743
Fix EventDispatcer & events
Looks like parameter for the `->dispatch(` have been flipped (event first then event name).
Define events should now extends `Symfony\Contracts\EventDispatcher\Event`
2022-12-15 21:47:31 +01:00
Jeremy Benoist aa5c7f05b8
Upgrade to Symfony 4.4
- disable autowiring for Event (because the Entry entity was injected)
- rename `getClient()` for test to `getTestClient()` to avoid error while overriding (from `BrowserKitAssertionsTrait`)
2022-11-29 18:01:46 -08:00
Jeremy Benoist b7dba18cb2
Cleanup 2022-11-23 15:51:33 +01:00
Jeremy Benoist 27e788d0be
Re-create all API routes 2022-11-23 12:44:55 +01:00
Casper Meijn 470a8575c0 Update to nelmio/api-doc 3.0
Convert ApiDoc to Swagger
2022-11-16 16:10:33 +01:00
Jeremy Benoist c372d68cc1
Merge remote-tracking branch 'origin/master' into 2.6.0 2022-10-18 11:11:02 +02:00
Yotam Nachum f994ab8b5d Add domain_name to entries api endpoint 2022-10-16 18:36:41 +03:00
Yassine Guedidi d1d56fbe25 Import used classes 2022-09-01 19:21:45 +02:00
Yassine Guedidi eb43c78720 Use FQCN instead of service alias 2022-09-01 09:07:19 +02:00
Yassine Guedidi 8b7b4975d6 Migrate getRepository with entities 2022-08-26 17:47:46 +02:00
Yassine Guedidi 0f9c359476 Use FQCN as service name for repositories 2022-08-24 23:24:25 +02:00
Yassine Guedidi 844e8e9d22 Use FQCN as service name for helper services 2022-08-24 23:24:24 +02:00
Kevin Decherf 19802d8bd5 Improve performance of REST exists call
I've noticed that the endpoint `/api/entries/exists` used by the "Sweep
articles" feature on the Android app failed almost all the time on my
instance.

After checking the corresponding method I found that
`EntryRestController::getEntriesExistsAction()` could be improved.

Here is the former way the method worked:

```
for id in [list of ids]
  get full entry by id
  if null
    get full entry by given id

return array of ids or array of hashes
```

With this behavior on my instance I could expect up to 13k SQL requests
when sweeping articles from the Android app. Morever the repository
fetches all fields (content included) while the method only returns ids
or hashes.

The new behavior is described as follow:

```
get ids, hashes by [list of ids]
merge with provided [list of ids] // this part will complete the final
                                  // array with not found ids

return array of ids or array of hashes
```

In my case this change reduces the number of SQL requests to only 135
(_considering one request for 50 articles_)

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2021-08-05 23:19:08 +02:00
Nicolas Lœuillet a07872238b
Fixed bug when we delete entry via API
Fixes #4291
2020-04-06 16:11:05 +02:00
Jeremy Benoist 8d4ed0df06
Update deps
Also CS (because cs-fixer got an update)

Package operations: 0 installs, 26 updates, 0 removals
  - Updating twig/twig (v2.12.1 => v2.12.2)
  - Updating symfony/symfony (v3.4.33 => v3.4.34)
  - Updating doctrine/event-manager (v1.0.0 => 1.1.0)
  - Updating doctrine/collections (v1.6.2 => 1.6.3)
  - Updating doctrine/cache (v1.8.1 => 1.9.0)
  - Updating doctrine/persistence (1.1.1 => 1.2.0)
  - Updating doctrine/inflector (v1.3.0 => 1.3.1)
  - Updating symfony/mime (v4.3.5 => v4.3.7)
  - Updating swiftmailer/swiftmailer (v6.2.1 => v6.2.3)
  - Updating symfony/swiftmailer-bundle (v3.3.0 => v3.3.1)
  - Updating doctrine/dbal (v2.9.2 => v2.9.3)
  - Updating doctrine/instantiator (1.2.0 => 1.3.0)
  - Updating j0k3r/graby-site-config (1.0.93 => 1.0.94)
  - Updating phpoption/phpoption (1.5.0 => 1.5.2)
  - Updating symfony/http-client-contracts (v1.1.7 => v1.1.8)
  - Updating symfony/http-client (v4.3.5 => v4.3.7)
  - Updating sensiolabs/security-checker (v6.0.2 => v6.0.3)
  - Updating paragonie/constant_time_encoding (v2.2.3 => v2.3.0)
  - Updating scheb/two-factor-bundle (v4.7.1 => v4.8.0)
  - Updating symfony/phpunit-bridge (v4.3.6 => v4.3.7)
  - Updating composer/xdebug-handler (1.3.3 => 1.4.0)
  - Updating friendsofphp/php-cs-fixer (v2.15.3 => v2.16.0)
  - Updating doctrine/data-fixtures (v1.3.2 => 1.3.3)
  - Updating nette/schema (v1.0.0 => v1.0.1)
  - Updating nikic/php-parser (v4.2.4 => v4.3.0)
  - Updating sentry/sentry (2.2.2 => 2.2.4)
2019-11-12 14:18:58 +01:00
Jeremy Benoist 52e8d93248
Fix some Scrutinizer issues 2019-05-29 12:50:44 +02:00
Jérémy Benoist 2cbee36a01
Merge pull request #3944 from shtrom/always-hash-exists-url
Always hash exists url
2019-05-28 14:18:33 +02:00
adev 5f08426201
Fix because of some breaking changes of Graby 2.0 2019-05-28 11:42:27 +02:00
Jeremy Benoist 629a3797bc
Remove useless methods
Also fix a phpdoc block
2019-05-24 15:46:28 +02:00
Olivier Mehani 4a5516376b
Add Wallabag\CoreBundle\Helper\UrlHasher
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
2019-05-24 15:17:46 +02:00
Olivier Mehani 31e276fc16
EntryRestController::getEntriesExistsAction: always find by hashed url
Simplify the logic from #3158 by hashing all the urls from the request,
and only doing a search by hash. This allows to get performance benefits
from the new indexed hash column even when using older clients that do
not hash the URL in the request.

Fixes: #3158, #3919

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
2019-05-24 15:17:45 +02:00
Kevin Decherf 2c290747cb api/entries: add parameter detail to exclude or include content in response
detail=metadata will nullify the content field of entries in order to
make smaller responses.

detail=full keeps the former behavior, it sends the content of entries.
It's the default, for backward compatibility.

Fixes #2817

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2019-05-18 18:11:08 +02:00
Jérémy Benoist 76bc05ebc0
Fix ApiDoc about md5/sha1 2019-04-02 22:59:50 +02:00
Jeremy Benoist c579ce2306
Some cleanup
Also, do not run the hashed_url migration into a Doctrine migration
2019-04-01 14:34:20 +02:00
Jeremy Benoist 9c2b2aae70
Keep url in exists endpoint
- Add migration
- Use md5 instead of sha512 (we don't need security here, just a hash)
- Update tests
2019-04-01 13:24:40 +02:00
Thomas Citharel bfe02a0b48
Hash the urls to check if they exist
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-04-01 13:24:40 +02:00
Jeremy Benoist 3620dae1e6
Merge remote-tracking branch 'origin/master' into 2.4 2019-04-01 13:16:15 +02:00
Kevin Decherf 508302042f EntryRestController: add support of expect parameter to delete action
The expect parameter enables an application to request the whole entry
or only the id when requesting its deletion.

`expects` defaults to `entry` to prevent any API breakage.

Fixes #3711

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2019-02-20 15:57:50 +01:00
Jeremy Benoist 8010425444
Fix third argument to Route 2019-01-22 20:42:25 +01:00
Jeremy Benoist 019e1acc49
Factorize sendResponse between Api controllers
And run newer cs fixer
2019-01-22 20:42:25 +01:00
Jeremy Benoist 5419a8368e
Merge remote-tracking branch 'origin/master' into 2.4 2019-01-15 09:41:18 +01:00
Jeremy Benoist 78e3fafa3f
Avoid error when a bad order parameter is given
Only allowed parameter are asc & desc
2019-01-14 17:01:21 +01:00
Sébastien Viande 0e70e81227
Entry: add sort parameter archived 2018-09-21 10:33:33 +02:00
Sébastien Viande 7975395d10
Entry: add archived_at property and updateArchived method 2018-09-21 10:33:33 +02:00
Kevin Decherf 2a1ceb67b4 php-cs-fixer
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2018-09-05 14:25:32 +02:00
Kevin Decherf f5ea67e4cf api: copy entry object before sending, to keep id
Workaround for https://github.com/wallabag/android-app/issues/646

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2017-12-17 21:07:46 +01:00
Kevin Decherf af29e1bf07 Fix empty title and domain_name when exception is thrown during fetch
Add a new helper to set a default title when it's empty:
1/ use basename part of entry's path, if any
2/ or use domain name

Fixes #2053

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2017-12-13 22:44:31 +01:00
Kevin Decherf 3b771f51a6 Improve origin_url field description and translations
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2017-11-19 15:02:11 +01:00
Kevin Decherf e0ef1a1c8b Add originUrl property to Entry, handle that in EntryRestController, handle migration
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
2017-11-19 15:02:11 +01:00
Sébastien Viande 0978bd849e Fix #3361 Entry Rest controller getEntries cast tags params to string 2017-10-13 10:28:05 +02:00
Jeremy Benoist f40c88eb1f
Jump to Symfony 3.3 & update others deps
Also update tests urls
2017-10-09 16:45:12 +02:00
François D a991c46eed Set a starred_at field when an entry is starred.
This date is used to sort starred entries.

Can not use Entry::timestamps method otherwise starred_at will be updated each time entry is updated.
Add an updateStar method into Entry class
A migration script has been added in order to set starred_at field.
2017-08-25 21:19:47 +02:00
Nicolas Hart 52b84c11a5 Fix some namespaces and phpdoc 2017-07-29 22:51:50 +02:00
Étienne Gilli 07320a2bd2 Use the article domain as author for export files
When exporting an entry, use the domain name as author name for epub,
mobi and pdf formats, instead of 'wallabag'.
Change the author from array to string, because for now, there is always
only one author.
2017-07-08 19:53:43 +02:00
Jeremy Benoist c18a2476b6
CS 2017-07-03 13:56:39 +02:00
Jeremy Benoist a05b61159e
Fix PATCH method
The PATCH method for the entry should only update what user sent to us and not the whole entry as it was before.
Also, sending tags when patching an entry will now remove all current tags & assocatied new ones.
2017-07-03 13:45:04 +02:00
Jeremy Benoist f808b01692
Add a real configuration for CS-Fixer 2017-07-01 09:52:38 +02:00
Jérémy Benoist 331e5b0261 CS 2017-06-28 09:18:22 +02:00
Jeremy Benoist 39ffaba323
Return null instead of false 2017-06-28 08:15:06 +02:00