diff --git a/lib/cache.js b/lib/cache.js index 219e6af..7f81cd7 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -70,6 +70,15 @@ exp.info = function(callback) { }); }; +// set model type to value of *slim* +exp.set_slim = function(rid, userId, slim, callback) { + logging.debug(rid, "setting slim for ", userId, "to " + slim); + // store userId in lower case if not null + userId = userId && userId.toLowerCase(); + + redis.hmset(userId, ["a", Number(slim)], callback); +}; + // sets the timestamp for +userId+ // if +temp+ is true, the timestamp is set so that the record will be outdated after 60 seconds // these 60 seconds match the duration of Mojang's rate limit ban @@ -134,7 +143,7 @@ exp.get_details = function(userId, callback) { details = { skin: data.s === "" ? null : data.s, cape: data.c === "" ? null : data.c, - slim: data.a === 1, + slim: data.a === "1", time: Number(data.t) }; } diff --git a/lib/helpers.js b/lib/helpers.js index 5859b7a..67a0468 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -19,9 +19,14 @@ function get_hash(url) { // gets the skin for +userId+ with +profile+ // uses +cache_details+ to determine if the skin needs to be downloaded or can be taken from cache // face and face+helm images are extracted and stored to files -// callback: error, skin hash +// callback: error, skin hash, callback function store_skin(rid, userId, profile, cache_details, callback) { networking.get_skin_info(rid, userId, profile, function(err, url, slim) { + if (!err && userId.length > 16) { + // updating username with model info from uuid details + cache.set_slim(rid, profile.name, slim); + } + if (!err && url) { var skin_hash = get_hash(url); if (cache_details && cache_details.skin === skin_hash) {