forked from Qortal/qortal
Added "followedonly" and "excludeblocked" params to GET /arbitrary/resources
and GET /arbitrary/resources/search
, as well as LIST_QDN_RESOURCES
and SEARCH_QDN_RESOURCES
Q-Apps actions.
This commit is contained in:
parent
250245d5e1
commit
61b7cdd025
@ -303,6 +303,8 @@ let res = await qortalRequest({
|
|||||||
default: true, // Optional
|
default: true, // Optional
|
||||||
includeStatus: false, // Optional - will take time to respond, so only request if necessary
|
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
|
includeMetadata: false, // Optional - will take time to respond, so only request if necessary
|
||||||
|
followedOnly: false, // Optional - include followed names only
|
||||||
|
excludeBlocked: false, // Optional - exclude blocked content
|
||||||
limit: 100,
|
limit: 100,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
reverse: true
|
reverse: true
|
||||||
@ -321,6 +323,8 @@ let res = await qortalRequest({
|
|||||||
default: false, // Optional - if true, only resources without identifiers are returned
|
default: false, // Optional - if true, only resources without identifiers are returned
|
||||||
includeStatus: false, // Optional - will take time to respond, so only request if necessary
|
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
|
includeMetadata: false, // Optional - will take time to respond, so only request if necessary
|
||||||
|
followedOnly: false, // Optional - include followed names only
|
||||||
|
excludeBlocked: false, // Optional - exclude blocked content
|
||||||
limit: 100,
|
limit: 100,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
reverse: true
|
reverse: true
|
||||||
|
@ -102,6 +102,8 @@ public class ArbitraryResource {
|
|||||||
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
||||||
@Parameter(ref = "offset") @QueryParam("offset") Integer offset,
|
@Parameter(ref = "offset") @QueryParam("offset") Integer offset,
|
||||||
@Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse,
|
@Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse,
|
||||||
|
@Parameter(description = "Include followed names only") @QueryParam("followedonly") Boolean followedOnly,
|
||||||
|
@Parameter(description = "Exclude blocked content") @QueryParam("excludeblocked") Boolean excludeBlocked,
|
||||||
@Parameter(description = "Filter names by list") @QueryParam("namefilter") String nameFilter,
|
@Parameter(description = "Filter names by list") @QueryParam("namefilter") String nameFilter,
|
||||||
@Parameter(description = "Include status") @QueryParam("includestatus") Boolean includeStatus,
|
@Parameter(description = "Include status") @QueryParam("includestatus") Boolean includeStatus,
|
||||||
@Parameter(description = "Include metadata") @QueryParam("includemetadata") Boolean includeMetadata) {
|
@Parameter(description = "Include metadata") @QueryParam("includemetadata") Boolean includeMetadata) {
|
||||||
@ -135,7 +137,7 @@ public class ArbitraryResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
|
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
|
||||||
.getArbitraryResources(service, identifier, names, defaultRes, limit, offset, reverse);
|
.getArbitraryResources(service, identifier, names, defaultRes, followedOnly, excludeBlocked, limit, offset, reverse);
|
||||||
|
|
||||||
if (resources == null) {
|
if (resources == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -178,6 +180,8 @@ public class ArbitraryResource {
|
|||||||
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
||||||
@Parameter(ref = "offset") @QueryParam("offset") Integer offset,
|
@Parameter(ref = "offset") @QueryParam("offset") Integer offset,
|
||||||
@Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse,
|
@Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse,
|
||||||
|
@Parameter(description = "Include followed names only") @QueryParam("followedonly") Boolean followedOnly,
|
||||||
|
@Parameter(description = "Exclude blocked content") @QueryParam("excludeblocked") Boolean excludeBlocked,
|
||||||
@Parameter(description = "Include status") @QueryParam("includestatus") Boolean includeStatus,
|
@Parameter(description = "Include status") @QueryParam("includestatus") Boolean includeStatus,
|
||||||
@Parameter(description = "Include metadata") @QueryParam("includemetadata") Boolean includeMetadata) {
|
@Parameter(description = "Include metadata") @QueryParam("includemetadata") Boolean includeMetadata) {
|
||||||
|
|
||||||
@ -192,7 +196,7 @@ public class ArbitraryResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
|
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
|
||||||
.searchArbitraryResources(service, query, identifier, names, usePrefixOnly, defaultRes, limit, offset, reverse);
|
.searchArbitraryResources(service, query, identifier, names, usePrefixOnly, defaultRes, followedOnly, excludeBlocked, limit, offset, reverse);
|
||||||
|
|
||||||
if (resources == null) {
|
if (resources == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -253,7 +257,7 @@ public class ArbitraryResource {
|
|||||||
String name = creatorName.name;
|
String name = creatorName.name;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
|
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
|
||||||
.getArbitraryResources(service, identifier, Arrays.asList(name), defaultRes, null, null, reverse);
|
.getArbitraryResources(service, identifier, Arrays.asList(name), defaultRes, null, null, null, null, reverse);
|
||||||
|
|
||||||
if (includeStatus != null && includeStatus) {
|
if (includeStatus != null && includeStatus) {
|
||||||
resources = ArbitraryTransactionUtils.addStatusToResources(resources);
|
resources = ArbitraryTransactionUtils.addStatusToResources(resources);
|
||||||
|
@ -24,9 +24,9 @@ public interface ArbitraryRepository {
|
|||||||
public ArbitraryTransactionData getLatestTransaction(String name, Service service, Method method, String identifier) throws DataException;
|
public ArbitraryTransactionData getLatestTransaction(String name, Service service, Method method, String identifier) throws DataException;
|
||||||
|
|
||||||
|
|
||||||
public List<ArbitraryResourceInfo> getArbitraryResources(Service service, String identifier, List<String> names, boolean defaultResource, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
public List<ArbitraryResourceInfo> getArbitraryResources(Service service, String identifier, List<String> names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||||
|
|
||||||
public List<ArbitraryResourceInfo> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly, boolean defaultResource, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
public List<ArbitraryResourceInfo> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||||
|
|
||||||
public List<ArbitraryResourceNameInfo> getArbitraryResourceCreatorNames(Service service, String identifier, boolean defaultResource, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
public List<ArbitraryResourceNameInfo> getArbitraryResourceCreatorNames(Service service, String identifier, boolean defaultResource, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import org.qortal.arbitrary.ArbitraryDataFile;
|
|||||||
import org.qortal.transaction.ArbitraryTransaction;
|
import org.qortal.transaction.ArbitraryTransaction;
|
||||||
import org.qortal.transaction.Transaction.ApprovalStatus;
|
import org.qortal.transaction.Transaction.ApprovalStatus;
|
||||||
import org.qortal.utils.Base58;
|
import org.qortal.utils.Base58;
|
||||||
|
import org.qortal.utils.ListUtils;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -284,7 +285,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArbitraryResourceInfo> getArbitraryResources(Service service, String identifier, List<String> names,
|
public List<ArbitraryResourceInfo> getArbitraryResources(Service service, String identifier, List<String> names,
|
||||||
boolean defaultResource, Integer limit, Integer offset, Boolean reverse) throws DataException {
|
boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked,
|
||||||
|
Integer limit, Integer offset, Boolean reverse) throws DataException {
|
||||||
StringBuilder sql = new StringBuilder(512);
|
StringBuilder sql = new StringBuilder(512);
|
||||||
List<Object> bindParams = new ArrayList<>();
|
List<Object> bindParams = new ArrayList<>();
|
||||||
|
|
||||||
@ -319,6 +321,36 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
sql.append(")");
|
sql.append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle "followed only"
|
||||||
|
if (followedOnly != null && followedOnly) {
|
||||||
|
List<String> followedNames = ListUtils.followedNames();
|
||||||
|
if (followedNames != null && !followedNames.isEmpty()) {
|
||||||
|
sql.append(" AND name IN (?");
|
||||||
|
bindParams.add(followedNames.get(0));
|
||||||
|
|
||||||
|
for (int i = 1; i < followedNames.size(); ++i) {
|
||||||
|
sql.append(", ?");
|
||||||
|
bindParams.add(followedNames.get(i));
|
||||||
|
}
|
||||||
|
sql.append(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle "exclude blocked"
|
||||||
|
if (excludeBlocked != null && excludeBlocked) {
|
||||||
|
List<String> blockedNames = ListUtils.blockedNames();
|
||||||
|
if (blockedNames != null && !blockedNames.isEmpty()) {
|
||||||
|
sql.append(" AND name NOT IN (?");
|
||||||
|
bindParams.add(blockedNames.get(0));
|
||||||
|
|
||||||
|
for (int i = 1; i < blockedNames.size(); ++i) {
|
||||||
|
sql.append(", ?");
|
||||||
|
bindParams.add(blockedNames.get(i));
|
||||||
|
}
|
||||||
|
sql.append(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sql.append(" GROUP BY name, service, identifier ORDER BY name COLLATE SQL_TEXT_UCC_NO_PAD");
|
sql.append(" GROUP BY name, service, identifier ORDER BY name COLLATE SQL_TEXT_UCC_NO_PAD");
|
||||||
|
|
||||||
if (reverse != null && reverse) {
|
if (reverse != null && reverse) {
|
||||||
@ -361,7 +393,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArbitraryResourceInfo> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly,
|
public List<ArbitraryResourceInfo> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly,
|
||||||
boolean defaultResource, Integer limit, Integer offset, Boolean reverse) throws DataException {
|
boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked,
|
||||||
|
Integer limit, Integer offset, Boolean reverse) throws DataException {
|
||||||
StringBuilder sql = new StringBuilder(512);
|
StringBuilder sql = new StringBuilder(512);
|
||||||
List<Object> bindParams = new ArrayList<>();
|
List<Object> bindParams = new ArrayList<>();
|
||||||
|
|
||||||
@ -417,6 +450,36 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
sql.append(")");
|
sql.append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle "followed only"
|
||||||
|
if (followedOnly != null && followedOnly) {
|
||||||
|
List<String> followedNames = ListUtils.followedNames();
|
||||||
|
if (followedNames != null && !followedNames.isEmpty()) {
|
||||||
|
sql.append(" AND name IN (?");
|
||||||
|
bindParams.add(followedNames.get(0));
|
||||||
|
|
||||||
|
for (int i = 1; i < followedNames.size(); ++i) {
|
||||||
|
sql.append(", ?");
|
||||||
|
bindParams.add(followedNames.get(i));
|
||||||
|
}
|
||||||
|
sql.append(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle "exclude blocked"
|
||||||
|
if (excludeBlocked != null && excludeBlocked) {
|
||||||
|
List<String> blockedNames = ListUtils.blockedNames();
|
||||||
|
if (blockedNames != null && !blockedNames.isEmpty()) {
|
||||||
|
sql.append(" AND name NOT IN (?");
|
||||||
|
bindParams.add(blockedNames.get(0));
|
||||||
|
|
||||||
|
for (int i = 1; i < blockedNames.size(); ++i) {
|
||||||
|
sql.append(", ?");
|
||||||
|
bindParams.add(blockedNames.get(i));
|
||||||
|
}
|
||||||
|
sql.append(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sql.append(" GROUP BY name, service, identifier ORDER BY date_created");
|
sql.append(" GROUP BY name, service, identifier ORDER BY date_created");
|
||||||
|
|
||||||
if (reverse != null && reverse) {
|
if (reverse != null && reverse) {
|
||||||
|
@ -190,6 +190,8 @@ window.addEventListener("message", (event) => {
|
|||||||
if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString());
|
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());
|
if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString());
|
||||||
if (data.includeMetadata != null) url = url.concat("&includemetadata=" + new Boolean(data.includeMetadata).toString());
|
if (data.includeMetadata != null) url = url.concat("&includemetadata=" + new Boolean(data.includeMetadata).toString());
|
||||||
|
if (data.followedOnly != null) url = url.concat("&followedonly=" + new Boolean(data.followedOnly).toString());
|
||||||
|
if (data.excludeBlocked != null) url = url.concat("&excludeblocked=" + new Boolean(data.excludeBlocked).toString());
|
||||||
if (data.limit != null) url = url.concat("&limit=" + data.limit);
|
if (data.limit != null) url = url.concat("&limit=" + data.limit);
|
||||||
if (data.offset != null) url = url.concat("&offset=" + data.offset);
|
if (data.offset != null) url = url.concat("&offset=" + data.offset);
|
||||||
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
|
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
|
||||||
@ -206,6 +208,8 @@ window.addEventListener("message", (event) => {
|
|||||||
if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString());
|
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());
|
if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString());
|
||||||
if (data.includeMetadata != null) url = url.concat("&includemetadata=" + new Boolean(data.includeMetadata).toString());
|
if (data.includeMetadata != null) url = url.concat("&includemetadata=" + new Boolean(data.includeMetadata).toString());
|
||||||
|
if (data.followedOnly != null) url = url.concat("&followedonly=" + new Boolean(data.followedOnly).toString());
|
||||||
|
if (data.excludeBlocked != null) url = url.concat("&excludeblocked=" + new Boolean(data.excludeBlocked).toString());
|
||||||
if (data.limit != null) url = url.concat("&limit=" + data.limit);
|
if (data.limit != null) url = url.concat("&limit=" + data.limit);
|
||||||
if (data.offset != null) url = url.concat("&offset=" + data.offset);
|
if (data.offset != null) url = url.concat("&offset=" + data.offset);
|
||||||
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
|
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user