Fetch avatars from different sources#469
Conversation
| return message.get('dateInt') * -1; | ||
| }, | ||
| initialize: function() { | ||
| this.on('add', function(message) { |
There was a problem hiding this comment.
in regards to consistent coding style and testability I'd suggest to move this anonymous callback to a method of this class and just have the wiring in the constructor ;)
| if (avatar.source != 'none'){ | ||
| message.set('senderImage', avatar.url); | ||
| } | ||
| }); |
There was a problem hiding this comment.
please add a .catch(console.error.bind(this)) at the end so that errors are logged to the console
| }); | ||
|
|
||
| Promise.resolve($.ajax(url)).then(function(avatar) { | ||
| if (avatar.source != 'none'){ |
| }, | ||
| initialize: function() { | ||
| this.on('add', function(message) { | ||
| var url = OC.generateUrl('apps/mail/avatars?email={email}', { |
There was a problem hiding this comment.
would be great to have this logic in a service of its own because then we can test this more easily ;)
|
|
||
| namespace OCA\Mail\Controller; | ||
|
|
||
| use Exception; |
| */ | ||
| public function show($email) { | ||
| // close the session to allow parallel downloads | ||
| $this->session->close(); |
There was a problem hiding this comment.
I don't think this is necessary if you don't annotate the controller with @UseSession. cc @LukasReschke
| } | ||
| } | ||
|
|
||
| __halt_compiler(); |
| use Gravatar\Gravatar; | ||
| use Mpclarkson\IconScraper\Scraper; | ||
|
|
||
| class AvatarService { |
There was a problem hiding this comment.
I'd really like to have this class tested. In its current form it's a bit difficult to do so. May I suggest to refactor this class into three classes for the individual avatar sources and just combine their results in this class? I can also take care of this, just let me know :)
| $response = $client->get($gravatarUrl); | ||
| } | ||
| catch (\Exception $exception) { | ||
| $foundGravatar = false; |
There was a problem hiding this comment.
just return null; here and remove the $foundAvatar stuff ;)
|
The avatars are now cached in |
|
@jakobsack what's your current status? The title and the tags are a bit contradictory :-P Btw, there seem to be conflicts with the composer deps. |
|
Sorry, I bricked my laptop last Friday. I'll try to add the last adjustments during this week. |
Take your time :) |
|
@jakobsack any update here or any way we can help? :) |
5ccd8e5 to
144297a
Compare
|
@ChristophWurst @Gomez Can you test the latest changes please? And tell me why composer won't work on travis? On my machine everything works fine :-/ |
|
I don't know why the MySQL version fails but it seems not to be related to my changes. |
Plus, we should check whether |
|
FYI: setting the yolo-no-review-but-merging-anyway-timeout to 2 weeks 😉 |
And we could add a background job that pre-poluates the cache 😉 |
|
@ChristophWurst will start reviewing now, meanwhile Fyi there are conflicting files. (And the package-lock.json should be in .gitignore maybe?) |
Thanks. Will take care of it.
Nope, that makes sure everyone installs the exact same version of a dependency and additionally also speeds up the installation of npm packages: https://docs.npmjs.com/files/package-lock.json |
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
|
So I did |
See #615 |
|
After switching folders now it seemed to load. :D |
jancborchardt
left a comment
There was a problem hiding this comment.
Weeeeeeee! Greaaat work!
|
Whoops now I was too happy about the approved review that I forgot to squash the commits 🙈 |
|
@jakobsack don't forget to claim your bounties for #463 and #236 😉 |
|
How is this configuration activated? I have nextcloud 13 & contacs 2.1.2. I load my contacts but avatars are not fetched. |
|
Please file a ticket for this bug. Thanks you. |

This implements parts of #463 and #236
When you open mail/avatars?email=test@example.com you get a JSON response
{ url: $url, source: $source }.
If no image has been found $url is null.