Added "name" filter to GET /arbitrary/resources and LIST_QDN_RESOURCES.

This commit is contained in:
CalDescent 2023-03-24 10:31:35 +00:00
parent 952d18390b
commit 929d0ac897
3 changed files with 11 additions and 3 deletions

View File

@ -299,7 +299,8 @@ let res = await qortalRequest({
let res = await qortalRequest({
action: "LIST_QDN_RESOURCES",
service: "THUMBNAIL",
identifier: "qortal_avatar", // Optional
name: "QortalDemo", // Optional (exact match)
identifier: "qortal_avatar", // Optional (exact match)
default: true, // Optional
includeStatus: false, // Optional - will take time to respond, so only request if necessary
includeMetadata: false, // Optional - will take time to respond, so only request if necessary

View File

@ -96,6 +96,7 @@ public class ArbitraryResource {
@ApiErrors({ApiError.REPOSITORY_ISSUE})
public List<ArbitraryResourceInfo> getResources(
@QueryParam("service") Service service,
@QueryParam("name") String name,
@QueryParam("identifier") String identifier,
@Parameter(description = "Default resources (without identifiers) only") @QueryParam("default") Boolean defaultResource,
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
@ -118,9 +119,14 @@ public class ArbitraryResource {
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.INVALID_CRITERIA, "identifier cannot be specified when requesting a default resource");
}
// Load filter from list if needed
// Set up name filters if supplied
List<String> names = null;
if (nameFilter != null) {
if (name != null) {
// Filter using single name
names = Arrays.asList(name);
}
else if (nameFilter != null) {
// Filter using supplied list of names
names = ResourceListManager.getInstance().getStringsInList(nameFilter);
if (names.isEmpty()) {
// List doesn't exist or is empty - so there will be no matches

View File

@ -166,6 +166,7 @@ window.addEventListener("message", (event) => {
case "LIST_QDN_RESOURCES":
url = "/arbitrary/resources?";
if (data.service != null) url = url.concat("&service=" + data.service);
if (data.name != null) url = url.concat("&name=" + data.name);
if (data.identifier != null) url = url.concat("&identifier=" + data.identifier);
if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString());
if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString());