forked from Qortal/qortal
Added GET /lists/blacklist/addresses API endpoint
This returns a JSON array containing the blacklisted addresses.
This commit is contained in:
parent
cd7adc997b
commit
481e6671c2
@ -237,6 +237,21 @@ public class ListsResource {
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/blacklist/addresses")
|
||||
@Operation(
|
||||
summary = "Fetch the list of blacklisted addresses",
|
||||
responses = {
|
||||
@ApiResponse(
|
||||
description = "A JSON array of addresses",
|
||||
content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(type = "boolean"))
|
||||
)
|
||||
}
|
||||
)
|
||||
public String getAddressBlacklist() {
|
||||
return ResourceListManager.getInstance().getBlacklistJSONString();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/blacklist/address/{address}")
|
||||
@Operation(
|
||||
|
@ -113,10 +113,12 @@ public class ResourceList {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Utils */
|
||||
|
||||
public static String listToJSONString(List<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
JSONArray items = new JSONArray();
|
||||
for (String item : list) {
|
||||
items.put(item);
|
||||
@ -125,6 +127,9 @@ public class ResourceList {
|
||||
}
|
||||
|
||||
private static List<String> listFromJSONString(String jsonString) {
|
||||
if (jsonString == null) {
|
||||
return null;
|
||||
}
|
||||
JSONArray jsonList = new JSONArray(jsonString);
|
||||
List<String> resourceList = new ArrayList<>();
|
||||
for (int i=0; i<jsonList.length(); i++) {
|
||||
@ -134,4 +139,8 @@ public class ResourceList {
|
||||
return resourceList;
|
||||
}
|
||||
|
||||
public String getJSONString() {
|
||||
return ResourceList.listToJSONString(this.list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class ResourceListManager {
|
||||
|
||||
@ -84,4 +85,11 @@ public class ResourceListManager {
|
||||
this.addressBlacklist.revert();
|
||||
}
|
||||
|
||||
public String getBlacklistJSONString() {
|
||||
if (this.addressBlacklist == null) {
|
||||
return null;
|
||||
}
|
||||
return this.addressBlacklist.getJSONString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user