forked from Qortal/qortal
Added haschatreference, with possible values of true, false, or null, to allow optional filtering by the presence or absense of a chat reference.
This commit is contained in:
parent
09014d07e0
commit
9d74f0eec0
@ -71,6 +71,7 @@ public class ChatResource {
|
|||||||
@QueryParam("involving") List<String> involvingAddresses,
|
@QueryParam("involving") List<String> involvingAddresses,
|
||||||
@QueryParam("reference") String reference,
|
@QueryParam("reference") String reference,
|
||||||
@QueryParam("chatreference") String chatReference,
|
@QueryParam("chatreference") String chatReference,
|
||||||
|
@QueryParam("haschatreference") Boolean hasChatReference,
|
||||||
@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) {
|
||||||
@ -104,6 +105,7 @@ public class ChatResource {
|
|||||||
txGroupId,
|
txGroupId,
|
||||||
referenceBytes,
|
referenceBytes,
|
||||||
chatReferenceBytes,
|
chatReferenceBytes,
|
||||||
|
hasChatReference,
|
||||||
involvingAddresses,
|
involvingAddresses,
|
||||||
limit, offset, reverse);
|
limit, offset, reverse);
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
|
@ -48,6 +48,7 @@ public class ChatMessagesWebSocket extends ApiWebSocket {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
sendMessages(session, chatMessages);
|
sendMessages(session, chatMessages);
|
||||||
@ -76,6 +77,7 @@ public class ChatMessagesWebSocket extends ApiWebSocket {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
involvingAddresses,
|
involvingAddresses,
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ public interface ChatRepository {
|
|||||||
* Expects EITHER non-null txGroupID OR non-null sender and recipient addresses.
|
* Expects EITHER non-null txGroupID OR non-null sender and recipient addresses.
|
||||||
*/
|
*/
|
||||||
public List<ChatMessage> getMessagesMatchingCriteria(Long before, Long after,
|
public List<ChatMessage> getMessagesMatchingCriteria(Long before, Long after,
|
||||||
Integer txGroupId, byte[] reference, byte[] chatReferenceBytes, List<String> involving,
|
Integer txGroupId, byte[] reference, byte[] chatReferenceBytes, Boolean hasChatReference,
|
||||||
Integer limit, Integer offset, Boolean reverse) throws DataException;
|
List<String> involving, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||||
|
|
||||||
public ChatMessage toChatMessage(ChatTransactionData chatTransactionData) throws DataException;
|
public ChatMessage toChatMessage(ChatTransactionData chatTransactionData) throws DataException;
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ public class HSQLDBChatRepository implements ChatRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ChatMessage> getMessagesMatchingCriteria(Long before, Long after, Integer txGroupId, byte[] referenceBytes,
|
public List<ChatMessage> getMessagesMatchingCriteria(Long before, Long after, Integer txGroupId, byte[] referenceBytes,
|
||||||
byte[] chatReferenceBytes, List<String> involving, Integer limit, Integer offset, Boolean reverse)
|
byte[] chatReferenceBytes, Boolean hasChatReference, List<String> involving,
|
||||||
throws DataException {
|
Integer limit, Integer offset, Boolean reverse) throws DataException {
|
||||||
// Check args meet expectations
|
// Check args meet expectations
|
||||||
if ((txGroupId != null && involving != null && !involving.isEmpty())
|
if ((txGroupId != null && involving != null && !involving.isEmpty())
|
||||||
|| (txGroupId == null && (involving == null || involving.size() != 2)))
|
|| (txGroupId == null && (involving == null || involving.size() != 2)))
|
||||||
@ -67,6 +67,13 @@ public class HSQLDBChatRepository implements ChatRepository {
|
|||||||
bindParams.add(chatReferenceBytes);
|
bindParams.add(chatReferenceBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasChatReference != null && hasChatReference == true) {
|
||||||
|
whereClauses.add("chat_reference IS NOT NULL");
|
||||||
|
}
|
||||||
|
else if (hasChatReference != null && hasChatReference == false) {
|
||||||
|
whereClauses.add("chat_reference IS NULL");
|
||||||
|
}
|
||||||
|
|
||||||
if (txGroupId != null) {
|
if (txGroupId != null) {
|
||||||
whereClauses.add("tx_group_id = " + txGroupId); // int safe to use literally
|
whereClauses.add("tx_group_id = " + txGroupId); // int safe to use literally
|
||||||
whereClauses.add("recipient IS NULL");
|
whereClauses.add("recipient IS NULL");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user