From 85c67212ad5f5a0d5ceb9104d4ed22d8e8e54457 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 4 Jul 2015 22:19:09 +0800 Subject: Added profile image on onlineList --- lib/realtime.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/realtime.js b/lib/realtime.js index 2f648c11..ca9cecd8 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -348,6 +348,7 @@ function buildUserOutData(user) { id: user.id, login: user.login, userid: user.userid, + photo: user.photo, color: user.color, cursor: user.cursor, name: user.name, @@ -361,24 +362,23 @@ function updateUserData(socket, user) { //retrieve user data from passport if (socket.request.user && socket.request.user.logged_in) { var profile = JSON.parse(socket.request.user.profile); - /* var photo = null; switch(profile.provider) { case "facebook": - console.log(profile); + photo = 'https://graph.facebook.com/' + profile.id + '/picture'; break; case "twitter": - photo = profile.photos[0]; + photo = profile.photos[0].value; break; case "github": - photo = profile.avatar_url; + photo = 'https://avatars.githubusercontent.com/u/' + profile.id + '?s=48'; break; case "dropbox": - //not image api provided + //no image api provided, use gravatar + photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0].value); break; } user.photo = photo; - */ user.name = profile.displayName || profile.username; user.userid = socket.request.user._id; user.login = true; -- cgit v1.2.3