فهرست منبع

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

jomo 9 سال پیش
والد
کامیت
fcdb03173a
2فایلهای تغییر یافته به همراه16 افزوده شده و 2 حذف شده
  1. 10 1
      lib/cache.js
  2. 6 1
      lib/helpers.js

+ 10 - 1
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)
       };
     }

+ 6 - 1
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) {