Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

fix(avatars): integrate the profile images backend #1584

Merged
merged 4 commits into from
Sep 16, 2014

Conversation

zaach
Copy link
Contributor

@zaach zaach commented Aug 21, 2014

We shouldn't merge this before the dev backend is ready: mozilla/fxa-dev#24.

Fixes #1556.

@zaach
Copy link
Contributor Author

zaach commented Aug 21, 2014

Functional tests are now working locally, but we need to wait for the fxa-dev server to be updated before we merge.

@zaach zaach removed the WIP label Aug 22, 2014
@zaach
Copy link
Contributor Author

zaach commented Aug 22, 2014

This is ready for review. @ckarlof or @nchapman


function t (s) { return s; }

var GRAVATAR_URL = 'https://www.gravatar.com/avatar/';
var EXPORT_LENGTH = 600;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's dis? 600px? 600chars?

@ckarlof
Copy link
Contributor

ckarlof commented Aug 26, 2014

Looks good, @zaach, but I would consider refactoring some of tests (particularly the view tests) to use mocked deps.

client_id: config.oauthClientId,
scope: 'profile:write'
};
var oauthClient = new OAuthClient({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing this, it would be cool to mock out the OAuthClient, ProfileClient, and Assertion modules and check that the expected methods on those objects are called with the expected parameters (e.g., the expected audience to Assertion.generate). In general, this is how we'd like to use mocks to test our objects, and I think this would be a good trial of using that approach (i.e., mocking out the direct object dependencies and not necessarily the actual servers).

@zaach zaach force-pushed the profile-images-backend branch 3 times, most recently from 3f97c56 to 69add1c Compare September 10, 2014 22:45
@zaach
Copy link
Contributor Author

zaach commented Sep 10, 2014

This is ready for another round of reviews.

@@ -25,7 +25,6 @@
<nav id="avatar-options">
<input type="file" id="imageLoader" name="imageLoader" accept="image/png, image/jpeg"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No GIFs? NNNOOOOOOOO!!!

//assert.equal(result, 'data:image/jpeg;base64,ohhai');
//});
//});
//});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ckarlof
Copy link
Contributor

ckarlof commented Sep 12, 2014

LGTM except for those commented out tests.

@ckarlof
Copy link
Contributor

ckarlof commented Sep 13, 2014

@shane-tomlinson I'll let you merge after you feel confident about whatever issue you were having running it.

@shane-tomlinson
Copy link

@zaach - verifier is now patched, thanks for that. Now I'm seeing other oddness:

I open http://127.0.0.1:3030/settings/avatar/camera, click on "Take picture", and in the profile server console, I see the following error:

[p18275] fxa.CRITICAL: Error: write EPIPE
    at errnoException (net.js:901:11)
    at Object.afterWrite (net.js:718:19)
[p18247] fxa.compute.CRITICAL: Fatal IPC error with image-cc.js compute process (18275) dies with code: 1
[nodemon] app crashed - waiting for file changes before starting...
[p18246] fxa.routes.avatar.upload.ERROR: Processing error Error: socket hang up
    at createHangUpError (http.js:1472:15)
    at Socket.socketOnEnd [as onend] (http.js:1568:23)
    at Socket.g (events.js:180:16)
    at Socket.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickDomainCallback (node.js:459:13)
[p18246] fxa.summary.ERROR: {"code":500,"errno":103,"path":"/v1/avatar/upload","agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:35.0) Gecko/20100101 Firefox/35.0","t":188,"stack":"Error: Image processing error\n    at Function.processingError (/Users/stomlinson/development/fxa-profile-server/lib/error.js:114:10)\n    at Request._callback (/Users/stomlinson/development/fxa-profile-server/lib/routes/avatar/upload.js:39:25)\n    at self.callback (/Users/stomlinson/development/fxa-profile-server/node_modules/request/request.js:123:22)\n    at Request.EventEmitter.emit (events.js:117:20)\n    at ClientRequest.self.clientErrorHandler (/Users/stomlinson/development/fxa-profile-server/node_modules/request/request.js:244:10)\n    at ClientRequest.EventEmitter.emit (events.js:95:17)\n    at Socket.socketOnEnd (http.js:1568:9)\n    at Socket.g (events.js:180:16)\n    at Socket.EventEmitter.emit (events.js:117:20)\n    at _stream_readable.js:920:16"}
[p18246] fxa.server.web.INFO: POST /v1/avatar/upload - 500 (193ms) <1410776360429-18246-51617>
[p18246] fxa.server.web.VERBOSE: Response: {
  "code": 500,
  "errno": 103,
  "error": "Internal Server Error",
  "message": "Image processing error",
  "_res": {
    "code": "ECONNRESET"
  }
} <1410776360429-18246-51617>

This results in an "incorrect password" message displayed to the user:

screen shot 2014-09-15 at 11 20 32

The request log to the profile server:

Request URL:    http://127.0.0.1:1111/v1/avatar/upload
Request Method:     POST
Status Code:    HTTP/1.1 500 Internal Server Error
Request Headers 11:22:14.000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:35.0) Gecko/20100101 Firefox/35.0
Referer:    http://127.0.0.1:3030/settings/avatar/camera
Pragma: no-cache
Origin: http://127.0.0.1:3030
Host:   127.0.0.1:1111
DNT:    1
Content-Type:   image/jpeg
Content-Length: 43863
Connection: keep-alive
Cache-Control:  no-cache
Authorization:  Bearer 20b25485929bd2f957e2ab9135ba29093661f65a6025e23b220b938e800fd431
Accept-Language:    en
Accept-Encoding:    gzip, deflate
Accept: application/json

Fetch the request body (42863 bytes)
Response Headers Δ8ms
Vary:   accept-encoding
Transfer-Encoding:  chunked
Date:   Mon, 15 Sep 2014 10:22:14 GMT
Content-Type:   application/json; charset=utf-8
Content-Encoding:   gzip
Connection: keep-alive
Cache-Control:  no-cache
access-control-max-age: 86400
access-control-expose-headers:  WWW-Authenticate, Server-Authorization
Access-Control-Allow-Origin:    *
access-control-allow-methods:   GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
access-control-allow-headers:   Authorization, Content-Type, If-None-Match
Response Body Δ0ms
{"code":500,"errno":103,"error":"Internal Server Error","message":"Image processing error","_res":{"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}}

@shane-tomlinson
Copy link

The above error is due to not having GraphicsMagick installed. Once that was installed, no problem. The error message should be changed to something other than incorrect password for this case.

@shane-tomlinson
Copy link

I do not know what caused this console error, but I see this:

NS_ERROR_NOT_AVAILABLE:  cropper.js:219

@shane-tomlinson
Copy link

@zaach - Every time I attempt to use a gravatar image, two calls are made to session/status, and then one to /avatar on the profile server. I keep receiving the error "No Gravatar found", even though this email address has an associated gravatar.

GET http://127.0.0.1:9000/v1/session/status [HTTP/1.1 200 OK 6ms]
GET http://127.0.0.1:9000/v1/session/status [HTTP/1.1 200 OK 16ms]
GET http://127.0.0.1:1111/v1/avatar [HTTP/1.1 200 OK 4ms]

@shane-tomlinson
Copy link

@zaach - should the image cropper be available when taking a snapshot from the camera?

@shane-tomlinson
Copy link

If I change my profile photo and visit /settings, the profile photo is displayed. If I sign out, sign back in, visit /settings, the profile photo is reset to the default. If I visit /settings/avatar, then go back to /settings, the photo appears.

@zaach
Copy link
Contributor Author

zaach commented Sep 15, 2014

@shane-tomlinson No image cropper after a camera photo, as per discussion with Ryan.

For /settings, I didn't want to add another network request to fetch the avatar until we enable avatar images in the UI. For now it's only fetched when you visit /settings/avatar. Should we go ahead and do a request in /settings anyway?

Fixes #1660.

This issue occurred because the context of an error was being discarded as the error was rethrown in the form submission handler. Rather than depend on error context being passed around, we store it on individual error objects.
@@ -11,14 +11,16 @@ define([
'lib/promise',
'lib/session',
'lib/auth-errors',
'lib/oauth-errors',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not actually used anywhere in base.

* remove unused deps from base.js.
* remove `errors` parameter in `displayError` calls in views/mixins/service-mixin
@coveralls
Copy link

Coverage Status

Coverage increased (+0.15%) when pulling 2160650 on profile-images-backend into a23ca63 on master.

shane-tomlinson pushed a commit that referenced this pull request Sep 16, 2014
fix(avatars): integrate the profile images backend

I give this my r+.
@shane-tomlinson shane-tomlinson merged commit 559516e into master Sep 16, 2014
@shane-tomlinson shane-tomlinson deleted the profile-images-backend branch September 16, 2014 09:54
@shane-tomlinson
Copy link

@zaach - I merged this as "good to go" but I still cannot use gravatar images. I am unsure if this is a problem with my setup, or whether this is a legitimate problem. If this is a problem, let's file a bug and open a follow on PR.

Nice work on this, and thanks for working through it with me!

@zaach
Copy link
Contributor Author

zaach commented Sep 16, 2014

@shane-tomlinson Hmm, what email address are you using? I can try it locally and see how it goes on my setup.

@shane-tomlinson
Copy link

@zaach - sent you an email with it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate profile images backend
5 participants