unfinished uuid refresh feature
This commit is contained in:
parent
2cc28e907d
commit
18c0868baf
@ -103,6 +103,8 @@ import net.frozenorb.apiv3.serialization.jackson.UuidJsonDeserializer;
|
||||
import net.frozenorb.apiv3.serialization.jackson.UuidJsonSerializer;
|
||||
import net.frozenorb.apiv3.serialization.mongodb.UuidCodecProvider;
|
||||
import net.frozenorb.apiv3.util.EmailUtils;
|
||||
import net.frozenorb.apiv3.util.MojangUtils;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
import org.bson.codecs.BsonValueCodecProvider;
|
||||
import org.bson.codecs.DocumentCodecProvider;
|
||||
@ -137,6 +139,24 @@ public final class APIv3 extends AbstractVerticle {
|
||||
setupMetrics();
|
||||
setupHttpServer();
|
||||
|
||||
User.findAll((users, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
for (User user : users) {
|
||||
String currentUsername = SyncUtils.runBlocking(v -> MojangUtils.getName(user.getId(), v));
|
||||
String lastUsername = user.getLastUsername();
|
||||
|
||||
if (!currentUsername.equals(lastUsername)) {
|
||||
SyncUtils.<Void>runBlocking(v -> user.checkNameCollisions(v));
|
||||
}
|
||||
|
||||
log.info(user.getLastUsername() + " - " + user.getLastSeenAt());
|
||||
}
|
||||
});
|
||||
|
||||
/*V2Importer converter = new V2Importer("mongodb://158.69.126.126", "minehq");
|
||||
|
||||
converter.startImport((ignored, error) -> {
|
||||
|
@ -63,6 +63,10 @@ public final class User {
|
||||
@Getter private Instant firstSeenAt;
|
||||
@Getter private boolean online;
|
||||
|
||||
public static void findAll(SingleResultCallback<List<User>> callback) {
|
||||
usersCollection.find().sort(new Document("lastSeenAt", -1)).into(new LinkedList<>(), SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public static void findById(String id, SingleResultCallback<User> callback) {
|
||||
try {
|
||||
findById(UuidUtils.parseUuid(id), callback);
|
||||
@ -79,7 +83,6 @@ public final class User {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void findOrCreateById(UUID id, String username, SingleResultCallback<User> callback) {
|
||||
if (!UuidUtils.isAcceptableUuid(id)) {
|
||||
callback.onResult(null, null);
|
||||
|
Loading…
Reference in New Issue
Block a user