Comparing version 0.1.2 to 0.1.3
# Changelog | ||
- 0.1.3 - Extra options: shouldFetchGmail and shouldFetchGravatar (Oct 13, 2017) | ||
- 0.1.0 - Redis supported and minor fixes (Jun 7, 2017) | ||
@@ -4,0 +5,0 @@ - 0.0.4 - Added Gravatar library (Apr 12, 2017) |
@@ -13,14 +13,26 @@ const async = require('async') | ||
this.cache = null | ||
this.shouldFetchGmail = true | ||
this.shouldFetchGravatar = true | ||
} | ||
configure (config) { | ||
this.defaultAvatar = config.defaultAvatar ? config.defaultAvatar : this.defaultAvatar | ||
this.defaultAvatarPath = config.defaultAvatarPath ? config.defaultAvatarPath : this.defaultAvatarPath | ||
this.cache = config.cache ? new Cache(config.cache) : null | ||
if (config) { | ||
this.defaultAvatar = config.defaultAvatar ? config.defaultAvatar : this.defaultAvatar | ||
this.defaultAvatarPath = config.defaultAvatarPath ? config.defaultAvatarPath : this.defaultAvatarPath | ||
this.cache = config.cache ? new Cache(config.cache) : null | ||
this.shouldFetchGmail = config.shouldFetchGmail !== undefined ? config.shouldFetchGmail : this.shouldFetchGmail | ||
this.shouldFetchGravatar = config.shouldFetchGravatar !== undefined ? config.shouldFetchGravatar : this.shouldFetchGravatar | ||
} | ||
} | ||
fetchAvatar (email, username, callback) { | ||
if (!email) return callback(new Error('No email provided'), null) | ||
if (!username) return callback(new Error('No username provided'), null) | ||
if (!this.isValidEmail(email)) return callback(new Error('No valid email'), null) | ||
if (!email) { | ||
return callback(new Error('No email provided'), null) | ||
} | ||
if (!username) { | ||
return callback(new Error('No username provided'), null) | ||
} | ||
if (!this.isValidEmail(email)) { | ||
return callback(new Error('No valid email'), null) | ||
} | ||
@@ -45,3 +57,3 @@ if (this.cache) { | ||
} | ||
/** | ||
@@ -54,2 +66,7 @@ * Fetch an avatar in multiple websites. | ||
gmail: (nextCb) => { | ||
console.log(this.shouldFetchGmail) | ||
if (this.shouldFetchGmail === false) { | ||
return nextCb(null, null) | ||
} | ||
this.fetchGoogleAvatar(email, (err, googleImage) => { | ||
@@ -61,2 +78,7 @@ if (err) return nextCb(null, null) | ||
gravatar: (nextCb) => { | ||
console.log(this.shouldFetchGravatar) | ||
if (this.shouldFetchGravatar === false) { | ||
return nextCb(null, null) | ||
} | ||
this.fethGravatarImage(email, (err, gravatarImage) => { | ||
@@ -63,0 +85,0 @@ if (err) return nextCb(null, null) |
{ | ||
"name": "avatar-me", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Simple node module to retrieves a user avatar given an email or a user name Edit", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -50,3 +50,5 @@ ![Avatar me logo](./assets/logo_avatar_me_npm_package_google_images.png) | ||
port: '6379' | ||
} | ||
}, | ||
shouldFetchGmail: false, | ||
shouldFetchGravatar: false | ||
}) | ||
@@ -53,0 +55,0 @@ |
@@ -9,3 +9,5 @@ var avatarMe = require('./index.js') | ||
port: '6379' | ||
} | ||
}, | ||
shouldFetchGmail: false, | ||
shouldFetchGravatar: false | ||
}) | ||
@@ -12,0 +14,0 @@ |
127369
170
65