Make all save and delete methods on models use void callbacks (instead of exposing Mongo's internal result)
This commit is contained in:
parent
ecaf008f66
commit
536de6d8b2
@ -3,14 +3,13 @@ package net.frozenorb.apiv3.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.actor.ActorType;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -64,12 +63,12 @@ public final class AccessToken {
|
||||
accessTokensCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
accessTokensCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
accessTokensCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
accessTokensCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
accessTokensCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -3,13 +3,12 @@ package net.frozenorb.apiv3.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -83,14 +82,14 @@ public final class BannedAsn {
|
||||
bannedAsnsCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
bannedAsnsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
bannedAsnsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
bannedAsnCache.remove(this);
|
||||
bannedAsnIdCache.remove(id);
|
||||
bannedAsnsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
bannedAsnsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -4,13 +4,12 @@ package net.frozenorb.apiv3.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -84,14 +83,14 @@ public final class BannedCellCarrier {
|
||||
bannedCellCarriersCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
bannedCellCarriersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
bannedCellCarriersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
bannedCellCarrierCache.remove(this);
|
||||
bannedCellCarrierIdCache.remove(id);
|
||||
bannedCellCarriersCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
bannedCellCarriersCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -3,12 +3,12 @@ package net.frozenorb.apiv3.model;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
@ -128,12 +128,12 @@ public final class Grant {
|
||||
grantsCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void delete(User removedBy, String reason, SingleResultCallback<UpdateResult> callback) {
|
||||
public void delete(User removedBy, String reason, SingleResultCallback<Void> callback) {
|
||||
this.removedBy = removedBy.getId();
|
||||
this.removedAt = Instant.now();
|
||||
this.removalReason = reason;
|
||||
|
||||
grantsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
grantsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,6 @@ package net.frozenorb.apiv3.model;
|
||||
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -10,6 +9,7 @@ import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.actor.Actor;
|
||||
import net.frozenorb.apiv3.actor.ActorType;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import net.frozenorb.apiv3.util.TimeUtils;
|
||||
import org.bson.Document;
|
||||
@ -149,12 +149,12 @@ public final class IpBan {
|
||||
ipBansCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void delete(User removedBy, String reason, SingleResultCallback<UpdateResult> callback) {
|
||||
public void delete(User removedBy, String reason, SingleResultCallback<Void> callback) {
|
||||
this.removedBy = removedBy.getId();
|
||||
this.removedAt = Instant.now();
|
||||
this.removalReason = reason;
|
||||
|
||||
ipBansCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
ipBansCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -2,12 +2,12 @@ package net.frozenorb.apiv3.model;
|
||||
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
@ -78,8 +78,8 @@ public final class IpLogEntry {
|
||||
ipLogCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
ipLogCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
ipLogCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -2,12 +2,12 @@ package net.frozenorb.apiv3.model;
|
||||
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -63,8 +63,8 @@ public final class NotificationTemplate {
|
||||
notificationTemplatesCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
notificationTemplatesCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
notificationTemplatesCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,6 @@ package net.frozenorb.apiv3.model;
|
||||
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -10,6 +9,7 @@ import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.actor.Actor;
|
||||
import net.frozenorb.apiv3.actor.ActorType;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import net.frozenorb.apiv3.util.TimeUtils;
|
||||
import org.bson.Document;
|
||||
@ -152,13 +152,13 @@ public final class Punishment {
|
||||
punishmentsCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void delete(User removedBy, String reason, SingleResultCallback<UpdateResult> callback) {
|
||||
public void delete(User removedBy, String reason, SingleResultCallback<Void> callback) {
|
||||
this.removedBy = removedBy.getId();
|
||||
this.removedAt = Instant.now();
|
||||
this.removalReason = reason;
|
||||
|
||||
if (linkedIpBanId == null) {
|
||||
punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -173,11 +173,11 @@ public final class Punishment {
|
||||
if (error2 != null) {
|
||||
callback.onResult(null, error2);
|
||||
} else {
|
||||
punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package net.frozenorb.apiv3.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -83,10 +83,10 @@ public final class Rank {
|
||||
ranksCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
rankCache.remove(this);
|
||||
rankIdCache.remove(id);
|
||||
ranksCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
ranksCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -4,13 +4,12 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.Getter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -125,14 +124,14 @@ public final class Server {
|
||||
serversCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
serversCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
serversCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
serverCache.remove(this);
|
||||
serverIdCache.remove(id);
|
||||
serversCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
serversCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -3,14 +3,13 @@ package net.frozenorb.apiv3.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.PermissionUtils;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import org.bson.Document;
|
||||
@ -78,14 +77,14 @@ public final class ServerGroup {
|
||||
serverGroupsCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
serverGroupsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
serverGroupsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
public void delete(SingleResultCallback<DeleteResult> callback) {
|
||||
public void delete(SingleResultCallback<Void> callback) {
|
||||
serverGroupCache.remove(this);
|
||||
serverGroupIdCache.remove(id);
|
||||
serverGroupsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback));
|
||||
serverGroupsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,6 @@ import com.google.common.hash.Hashing;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
import fr.javatic.mongo.jacksonCodec.objectId.Id;
|
||||
import io.vertx.core.CompositeFuture;
|
||||
@ -24,10 +23,7 @@ import net.frozenorb.apiv3.maxmind.MaxMindUserType;
|
||||
import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies;
|
||||
import net.frozenorb.apiv3.serialization.jackson.UuidJsonDeserializer;
|
||||
import net.frozenorb.apiv3.serialization.jackson.UuidJsonSerializer;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVertxCallback;
|
||||
import net.frozenorb.apiv3.unsorted.Permissions;
|
||||
import net.frozenorb.apiv3.unsorted.RequiresTotpResult;
|
||||
import net.frozenorb.apiv3.unsorted.TotpAuthorizationResult;
|
||||
import net.frozenorb.apiv3.unsorted.*;
|
||||
import net.frozenorb.apiv3.util.*;
|
||||
import org.bson.Document;
|
||||
|
||||
@ -614,8 +610,8 @@ public final class User {
|
||||
usersCollection.insertOne(this, SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public void save(SingleResultCallback<UpdateResult> callback) {
|
||||
usersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback));
|
||||
public void save(SingleResultCallback<Void> callback) {
|
||||
usersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback)));
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.accessTokens;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -23,7 +22,8 @@ public final class DELETEAccessTokensId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<DeleteResult>runBlocking(v -> accessToken.delete(v));
|
||||
SyncUtils.<Void>runBlocking(v -> accessToken.delete(v));
|
||||
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
|
||||
if (requestBody.containsKey("removedBy")) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.bannedAsns;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -23,7 +22,7 @@ public final class DELETEBannedAsnsId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<DeleteResult>runBlocking(v -> bannedAsn.delete(v));
|
||||
SyncUtils.<Void>runBlocking(v -> bannedAsn.delete(v));
|
||||
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.bannedCellCarriers;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -23,7 +22,7 @@ public final class DELETEBannedCellCarriersId implements Handler<RoutingContext>
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<DeleteResult>runBlocking(v -> bannedCellCarrier.delete(v));
|
||||
SyncUtils.<Void>runBlocking(v -> bannedCellCarrier.delete(v));
|
||||
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.emailTokens;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -44,7 +43,7 @@ public final class POSTEmailTokensIdConfirm implements Handler<RoutingContext> {
|
||||
|
||||
user.completeEmailRegistration(user.getPendingEmail());
|
||||
user.updatePassword(password);
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_CONFIRM_EMAIL, (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.grants;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -41,7 +40,7 @@ public final class DELETEGrantsId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> grant.delete(removedBy, reason, v));
|
||||
SyncUtils.<Void>runBlocking(v -> grant.delete(removedBy, reason, v));
|
||||
|
||||
AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.GRANT_DELETE, ImmutableMap.of("grantId", grant.getId()), (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.ipBans;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -41,7 +40,7 @@ public final class DELETEIpBansId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> ipBan.delete(removedBy, reason, v));
|
||||
SyncUtils.<Void>runBlocking(v -> ipBan.delete(removedBy, reason, v));
|
||||
|
||||
AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.IP_BAN_DELETE, ImmutableMap.of("punishmentId", ipBan.getId()), (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.notificationTemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -23,7 +22,7 @@ public final class DELETENotificationTemplatesId implements Handler<RoutingConte
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<DeleteResult>runBlocking(v -> notificationTemplate.delete(v));
|
||||
SyncUtils.<Void>runBlocking(v -> notificationTemplate.delete(v));
|
||||
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.punishments;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -41,7 +40,7 @@ public final class DELETEPunishmentsId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> punishment.delete(removedBy, reason, v));
|
||||
SyncUtils.<Void>runBlocking(v -> punishment.delete(removedBy, reason, v));
|
||||
|
||||
AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.PUNISHMENT_DELETE, ImmutableMap.of("punishmentId", punishment.getId()), (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -2,7 +2,6 @@ package net.frozenorb.apiv3.route.punishments;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -58,7 +57,7 @@ public final class DELETEUsersIdActivePunishment implements Handler<RoutingConte
|
||||
}
|
||||
|
||||
Punishment finalActivePunishment = activePunishment;
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> finalActivePunishment.delete(removedBy, reason, v));
|
||||
SyncUtils.<Void>runBlocking(v -> finalActivePunishment.delete(removedBy, reason, v));
|
||||
|
||||
AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.PUNISHMENT_DELETE, ImmutableMap.of("punishmentId", activePunishment.getId()), (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.ranks;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -23,7 +22,7 @@ public final class DELETERanksId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<DeleteResult>runBlocking(v -> rank.delete(v));
|
||||
SyncUtils.<Void>runBlocking(v -> rank.delete(v));
|
||||
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.serverGroups;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -23,7 +22,7 @@ public final class DELETEServerGroupsId implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
SyncUtils.<DeleteResult>runBlocking(v -> serverGroup.delete(v));
|
||||
SyncUtils.<Void>runBlocking(v -> serverGroup.delete(v));
|
||||
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -71,7 +70,7 @@ public final class POSTUsersIdChangePassword implements Handler<RoutingContext>
|
||||
}
|
||||
|
||||
user.updatePassword(newPassword);
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_CHANGE_PASSWORD, (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -54,14 +53,14 @@ public final class POSTUsersIdConfirmPhone implements Handler<RoutingContext> {
|
||||
|
||||
if (!String.valueOf(phoneCode).equals(user.getPendingPhoneToken())) {
|
||||
user.failedPhoneRegistration();
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
ErrorUtils.respondOther(ctx, 409, "Phone token doesn't match", "phoneTokenNoMatch", ImmutableMap.of());
|
||||
return;
|
||||
}
|
||||
|
||||
user.completePhoneRegistration(user.getPendingPhone());
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_CONFIRM_PHONE, (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -69,7 +68,7 @@ public final class POSTUsersIdLogin implements Handler<RoutingContext> {
|
||||
ipLogEntry.used();
|
||||
|
||||
IpLogEntry finalIpLogEntry = ipLogEntry;
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> finalIpLogEntry.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> finalIpLogEntry.save(v));
|
||||
}
|
||||
|
||||
String lastUsername = user.getLastUsername();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -33,7 +32,7 @@ public final class POSTUsersIdPasswordReset implements Handler<RoutingContext> {
|
||||
}
|
||||
|
||||
user.startPasswordReset();
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
Map<String, Object> replacements = ImmutableMap.of(
|
||||
"username", user.getLastUsername(),
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -59,7 +58,7 @@ public final class POSTUsersIdRegisterEmail implements Handler<RoutingContext> {
|
||||
}
|
||||
|
||||
user.startEmailRegistration(email);
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
Map<String, Object> replacements = ImmutableMap.of(
|
||||
"username", user.getLastUsername(),
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -63,7 +62,7 @@ public final class POSTUsersIdRegisterPhone implements Handler<RoutingContext> {
|
||||
}
|
||||
|
||||
user.startPhoneRegistration(phone);
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
Map<String, Object> replacements = ImmutableMap.of(
|
||||
"username", user.getLastUsername(),
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.frozenorb.apiv3.route.users;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@ -34,7 +33,7 @@ public final class POSTUsersIdSetupTotp implements Handler<RoutingContext> {
|
||||
|
||||
if (TotpUtils.authorizeUser(secret, totpCode)) {
|
||||
user.setTotpSecret(secret);
|
||||
SyncUtils.<UpdateResult>runBlocking(v -> user.save(v));
|
||||
SyncUtils.<Void>runBlocking(v -> user.save(v));
|
||||
|
||||
AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_SETUP_TOTP, (ignored, error) -> {
|
||||
if (error != null) {
|
||||
|
@ -3,7 +3,7 @@ package net.frozenorb.apiv3.unsorted;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import io.vertx.core.Future;
|
||||
|
||||
public class MongoToVertxCallback<T> implements SingleResultCallback<T> {
|
||||
public final class MongoToVertxCallback<T> implements SingleResultCallback<T> {
|
||||
|
||||
private final Future<T> future;
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package net.frozenorb.apiv3.unsorted;
|
||||
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
|
||||
public final class MongoToVoidMongoCallback<T> implements SingleResultCallback<T> {
|
||||
|
||||
private final SingleResultCallback<Void> wrapped;
|
||||
|
||||
public MongoToVoidMongoCallback(SingleResultCallback<Void> wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
public void onResult(T ignored, Throwable error) {
|
||||
wrapped.onResult(null, error);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user