Browse Source

Added GET /chat/message/{signature} endpoint.

This will ease the transition to a Q-Chat protocol, where chat messages will no longer be regular transactions.
null-owned-groups
CalDescent 2 years ago
parent
commit
02ac6dd8c1
  1. 32
      src/main/java/org/qortal/api/resource/ChatResource.java

32
src/main/java/org/qortal/api/resource/ChatResource.java

@ -99,6 +99,38 @@ public class ChatResource {
}
}
@GET
@Path("/message/{signature}")
@Operation(
summary = "Find chat message by signature",
responses = {
@ApiResponse(
description = "CHAT message",
content = @Content(
schema = @Schema(
implementation = ChatMessage.class
)
)
)
}
)
@ApiErrors({ApiError.INVALID_CRITERIA, ApiError.INVALID_ADDRESS, ApiError.REPOSITORY_ISSUE})
public ChatMessage getMessageBySignature(@QueryParam("signature") String signature58) {
byte[] signature = Base58.decode(signature58);
try (final Repository repository = RepositoryManager.getRepository()) {
ChatTransactionData chatTransactionData = (ChatTransactionData) repository.getTransactionRepository().fromSignature(signature);
if (chatTransactionData == null) {
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.INVALID_CRITERIA, "Message not found");
}
return repository.getChatRepository().toChatMessage(chatTransactionData);
} catch (DataException e) {
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
}
}
@GET
@Path("/active/{address}")
@Operation(

Loading…
Cancel
Save