3
0
mirror of https://github.com/Qortal/qortal.git synced 2025-02-12 18:25:49 +00:00

Fixed issues retrieving chatReference from the db.

This commit is contained in:
CalDescent 2022-10-23 19:29:31 +01:00
parent 1dd039fb2d
commit 09014d07e0
2 changed files with 18 additions and 9 deletions

View File

@ -27,6 +27,8 @@ public class ChatMessage {
private String recipientName; private String recipientName;
private byte[] chatReference;
private byte[] data; private byte[] data;
private boolean isText; private boolean isText;
@ -42,8 +44,8 @@ public class ChatMessage {
// For repository use // For repository use
public ChatMessage(long timestamp, int txGroupId, byte[] reference, byte[] senderPublicKey, String sender, public ChatMessage(long timestamp, int txGroupId, byte[] reference, byte[] senderPublicKey, String sender,
String senderName, String recipient, String recipientName, byte[] data, boolean isText, String senderName, String recipient, String recipientName, byte[] chatReference, byte[] data,
boolean isEncrypted, byte[] signature) { boolean isText, boolean isEncrypted, byte[] signature) {
this.timestamp = timestamp; this.timestamp = timestamp;
this.txGroupId = txGroupId; this.txGroupId = txGroupId;
this.reference = reference; this.reference = reference;
@ -52,6 +54,7 @@ public class ChatMessage {
this.senderName = senderName; this.senderName = senderName;
this.recipient = recipient; this.recipient = recipient;
this.recipientName = recipientName; this.recipientName = recipientName;
this.chatReference = chatReference;
this.data = data; this.data = data;
this.isText = isText; this.isText = isText;
this.isEncrypted = isEncrypted; this.isEncrypted = isEncrypted;
@ -90,6 +93,10 @@ public class ChatMessage {
return this.recipientName; return this.recipientName;
} }
public byte[] getChatReference() {
return this.chatReference;
}
public byte[] getData() { public byte[] getData() {
return this.data; return this.data;
} }

View File

@ -35,7 +35,7 @@ public class HSQLDBChatRepository implements ChatRepository {
sql.append("SELECT created_when, tx_group_id, Transactions.reference, creator, " sql.append("SELECT created_when, tx_group_id, Transactions.reference, creator, "
+ "sender, SenderNames.name, recipient, RecipientNames.name, " + "sender, SenderNames.name, recipient, RecipientNames.name, "
+ "data, is_text, is_encrypted, signature " + "chat_reference, data, is_text, is_encrypted, signature "
+ "FROM ChatTransactions " + "FROM ChatTransactions "
+ "JOIN Transactions USING (signature) " + "JOIN Transactions USING (signature) "
+ "LEFT OUTER JOIN Names AS SenderNames ON SenderNames.owner = sender " + "LEFT OUTER JOIN Names AS SenderNames ON SenderNames.owner = sender "
@ -108,13 +108,14 @@ public class HSQLDBChatRepository implements ChatRepository {
String senderName = resultSet.getString(6); String senderName = resultSet.getString(6);
String recipient = resultSet.getString(7); String recipient = resultSet.getString(7);
String recipientName = resultSet.getString(8); String recipientName = resultSet.getString(8);
byte[] data = resultSet.getBytes(9); byte[] chatReference = resultSet.getBytes(9);
boolean isText = resultSet.getBoolean(10); byte[] data = resultSet.getBytes(10);
boolean isEncrypted = resultSet.getBoolean(11); boolean isText = resultSet.getBoolean(11);
byte[] signature = resultSet.getBytes(12); boolean isEncrypted = resultSet.getBoolean(12);
byte[] signature = resultSet.getBytes(13);
ChatMessage chatMessage = new ChatMessage(timestamp, groupId, reference, senderPublicKey, sender, ChatMessage chatMessage = new ChatMessage(timestamp, groupId, reference, senderPublicKey, sender,
senderName, recipient, recipientName, data, isText, isEncrypted, signature); senderName, recipient, recipientName, chatReference, data, isText, isEncrypted, signature);
chatMessages.add(chatMessage); chatMessages.add(chatMessage);
} while (resultSet.next()); } while (resultSet.next());
@ -146,13 +147,14 @@ public class HSQLDBChatRepository implements ChatRepository {
byte[] senderPublicKey = chatTransactionData.getSenderPublicKey(); byte[] senderPublicKey = chatTransactionData.getSenderPublicKey();
String sender = chatTransactionData.getSender(); String sender = chatTransactionData.getSender();
String recipient = chatTransactionData.getRecipient(); String recipient = chatTransactionData.getRecipient();
byte[] chatReference = chatTransactionData.getChatReference();
byte[] data = chatTransactionData.getData(); byte[] data = chatTransactionData.getData();
boolean isText = chatTransactionData.getIsText(); boolean isText = chatTransactionData.getIsText();
boolean isEncrypted = chatTransactionData.getIsEncrypted(); boolean isEncrypted = chatTransactionData.getIsEncrypted();
byte[] signature = chatTransactionData.getSignature(); byte[] signature = chatTransactionData.getSignature();
return new ChatMessage(timestamp, groupId, reference, senderPublicKey, sender, return new ChatMessage(timestamp, groupId, reference, senderPublicKey, sender,
senderName, recipient, recipientName, data, isText, isEncrypted, signature); senderName, recipient, recipientName, chatReference, data, isText, isEncrypted, signature);
} catch (SQLException e) { } catch (SQLException e) {
throw new DataException("Unable to fetch convert chat transaction from repository", e); throw new DataException("Unable to fetch convert chat transaction from repository", e);
} }