Cleanup keybase query a bit

Remove ctime and the cached key, making the query for the entire user
object unnecessary. This should only be done when the user decides to
import the key. Hopefully keybase.io can provide all info necessary in
the search results.
This commit is contained in:
Thialfihar 2014-05-14 14:17:20 +02:00
parent 056a6dd347
commit 2480844884

View File

@ -88,12 +88,14 @@ public class KeybaseKeyServer extends KeyServer {
private ImportKeysListEntry makeEntry(JSONObject match) throws QueryException, JSONException { private ImportKeysListEntry makeEntry(JSONObject match) throws QueryException, JSONException {
String key_fingerprint = JWalk.getString(match, "components", "key_fingerprint", "val");
key_fingerprint = key_fingerprint.replace(" ", "").toUpperCase();
match = getUser(keybaseID);
final ImportKeysListEntry entry = new ImportKeysListEntry(); final ImportKeysListEntry entry = new ImportKeysListEntry();
String keybaseId = JWalk.getString(match, "components", "username", "val"); String keybaseId = JWalk.getString(match, "components", "username", "val");
String fullName = JWalk.getString(match, "components", "full_name", "val");
String fingerprint = JWalk.getString(match, "components", "key_fingerprint", "val");
fingerprint = fingerprint.replace(" ", "").toUpperCase();
// in anticipation of a full fingerprint, only use the last 16 chars as 64-bit key id
entry.setKeyIdHex("0x" + fingerprint.substring(Math.max(0, fingerprint.length() - 16)));
// store extra info, so we can query for the keybase id directly // store extra info, so we can query for the keybase id directly
entry.setExtraData(keybaseId); entry.setExtraData(keybaseId);
@ -101,20 +103,17 @@ public class KeybaseKeyServer extends KeyServer {
//entry.setBitStrength(4096); //entry.setBitStrength(4096);
//entry.setAlgorithm("RSA"); //entry.setAlgorithm("RSA");
// ctime entry.setFingerprintHex(fingerprint);
final long creationDate = JWalk.getLong(match, "them", "public_keys", "primary", "ctime");
final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
tmpGreg.setTimeInMillis(creationDate * 1000);
entry.setDate(tmpGreg.getTime());
// key bits // key data
// we have to fetch the user object to construct the search-result list, so we might as // currently there's no need to query the user right away, and it should be avoided, so the
// well (weakly) remember the key, in case they try to import it // user doesn't experience lag and doesn't download many keys unnecessarily, but should we
mKeyCache.put(keybaseID, JWalk.getString(match,"them", "public_keys", "primary", "bundle")); // require to do it at soe point:
// (weakly) remember the key, in case the user tries to import it
//mKeyCache.put(keybaseId, JWalk.getString(match, "them", "public_keys", "primary", "bundle"));
// String displayName = JWalk.getString(match, "them", "profile", "full_name");
ArrayList<String> userIds = new ArrayList<String>(); ArrayList<String> userIds = new ArrayList<String>();
String name = "keybase.io/" + keybaseID + " <" + keybaseID + "@keybase.io>"; String name = fullName + " <keybase.io/" + keybaseId + ">";
userIds.add(name); userIds.add(name);
entry.setUserIds(userIds); entry.setUserIds(userIds);
entry.setPrimaryUserId(name); entry.setPrimaryUserId(name);