forked from Qortal/qortal
Re-add missing senderName & recipientName to output of API call GET /chat/messages
This commit is contained in:
parent
7102f4a727
commit
51bfd49e25
@ -17,9 +17,14 @@ public class ChatMessage {
|
||||
/* Address of sender */
|
||||
private String sender;
|
||||
|
||||
// Not always present
|
||||
private String senderName;
|
||||
|
||||
/* Address of recipient (if any) */
|
||||
private String recipient; // can be null
|
||||
|
||||
private String recipientName;
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private boolean isText;
|
||||
@ -32,13 +37,15 @@ public class ChatMessage {
|
||||
}
|
||||
|
||||
// For repository use
|
||||
public ChatMessage(long timestamp, int txGroupId, byte[] senderPublicKey, String sender,
|
||||
String recipient, byte[] data, boolean isText, boolean isEncrypted) {
|
||||
public ChatMessage(long timestamp, int txGroupId, byte[] senderPublicKey, String sender, String senderName,
|
||||
String recipient, String recipientName, byte[] data, boolean isText, boolean isEncrypted) {
|
||||
this.timestamp = timestamp;
|
||||
this.txGroupId = txGroupId;
|
||||
this.senderPublicKey = senderPublicKey;
|
||||
this.sender = sender;
|
||||
this.senderName = senderName;
|
||||
this.recipient = recipient;
|
||||
this.recipientName = recipientName;
|
||||
this.data = data;
|
||||
this.isText = isText;
|
||||
this.isEncrypted = isEncrypted;
|
||||
@ -60,10 +67,18 @@ public class ChatMessage {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public String getSenderName() {
|
||||
return this.senderName;
|
||||
}
|
||||
|
||||
public String getRecipient() {
|
||||
return this.recipient;
|
||||
}
|
||||
|
||||
public String getRecipientName() {
|
||||
return this.recipientName;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
@ -32,9 +32,12 @@ public class HSQLDBChatRepository implements ChatRepository {
|
||||
|
||||
StringBuilder sql = new StringBuilder(1024);
|
||||
|
||||
sql.append("SELECT created_when, tx_group_id, creator, sender, recipient, data, is_text, is_encrypted "
|
||||
sql.append("SELECT created_when, tx_group_id, creator, sender, SenderNames.name, "
|
||||
+ "recipient, RecipientNames.name, data, is_text, is_encrypted "
|
||||
+ "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 RecipientNames ON RecipientNames.owner = recipient ");
|
||||
|
||||
// WHERE clauses
|
||||
|
||||
@ -89,13 +92,15 @@ public class HSQLDBChatRepository implements ChatRepository {
|
||||
int groupId = resultSet.getInt(2);
|
||||
byte[] senderPublicKey = resultSet.getBytes(3);
|
||||
String sender = resultSet.getString(4);
|
||||
String recipient = resultSet.getString(5);
|
||||
byte[] data = resultSet.getBytes(6);
|
||||
boolean isText = resultSet.getBoolean(7);
|
||||
boolean isEncrypted = resultSet.getBoolean(8);
|
||||
String senderName = resultSet.getString(5);
|
||||
String recipient = resultSet.getString(6);
|
||||
String recipientName = resultSet.getString(7);
|
||||
byte[] data = resultSet.getBytes(8);
|
||||
boolean isText = resultSet.getBoolean(9);
|
||||
boolean isEncrypted = resultSet.getBoolean(10);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(timestamp, groupId, senderPublicKey, sender,
|
||||
recipient, data, isText, isEncrypted);
|
||||
ChatMessage chatMessage = new ChatMessage(timestamp, groupId, senderPublicKey, sender, senderName,
|
||||
recipient, recipientName, data, isText, isEncrypted);
|
||||
|
||||
chatMessages.add(chatMessage);
|
||||
} while (resultSet.next());
|
||||
|
Loading…
Reference in New Issue
Block a user