Use UUID's profileName response to update username model type, see #125

This commit is contained in:
jomo 2016-01-13 02:15:47 +01:00
parent 1f0f696151
commit fcdb03173a
2 changed files with 16 additions and 2 deletions

View File

@ -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)
};
}

View File

@ -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) {