mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 16:01:16 +01:00
Use UUID's profileName response to update username model type, see #125
This commit is contained in:
parent
1f0f696151
commit
fcdb03173a
11
lib/cache.js
11
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+
|
// sets the timestamp for +userId+
|
||||||
// if +temp+ is true, the timestamp is set so that the record will be outdated after 60 seconds
|
// 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
|
// these 60 seconds match the duration of Mojang's rate limit ban
|
||||||
@ -134,7 +143,7 @@ exp.get_details = function(userId, callback) {
|
|||||||
details = {
|
details = {
|
||||||
skin: data.s === "" ? null : data.s,
|
skin: data.s === "" ? null : data.s,
|
||||||
cape: data.c === "" ? null : data.c,
|
cape: data.c === "" ? null : data.c,
|
||||||
slim: data.a === 1,
|
slim: data.a === "1",
|
||||||
time: Number(data.t)
|
time: Number(data.t)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,9 +19,14 @@ function get_hash(url) {
|
|||||||
// gets the skin for +userId+ with +profile+
|
// 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
|
// 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
|
// 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) {
|
function store_skin(rid, userId, profile, cache_details, callback) {
|
||||||
networking.get_skin_info(rid, userId, profile, function(err, url, slim) {
|
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) {
|
if (!err && url) {
|
||||||
var skin_hash = get_hash(url);
|
var skin_hash = get_hash(url);
|
||||||
if (cache_details && cache_details.skin === skin_hash) {
|
if (cache_details && cache_details.skin === skin_hash) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user