SHA256
Исправить отображение версий в дневнике и тредах
This commit is contained in:
+6
-2
@@ -214,8 +214,12 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
first.setCreatedAtMs(base.createdAtMs);
|
||||
versions.add(first);
|
||||
|
||||
if (row.msgSubType == MsgSubType.TEXT_REPLY || ChannelsReadSupport.supportsEditPostVersions(row.msgSubType)) {
|
||||
short editType = row.msgSubType == MsgSubType.TEXT_REPLY ? MsgSubType.TEXT_EDIT_REPLY : MsgSubType.TEXT_EDIT_POST;
|
||||
if (row.msgSubType == MsgSubType.TEXT_REPLY
|
||||
|| row.msgSubType == MsgSubType.TEXT_RATING
|
||||
|| ChannelsReadSupport.supportsEditPostVersions(row.msgSubType)) {
|
||||
short editType = (row.msgSubType == MsgSubType.TEXT_REPLY || row.msgSubType == MsgSubType.TEXT_RATING)
|
||||
? MsgSubType.TEXT_EDIT_REPLY
|
||||
: MsgSubType.TEXT_EDIT_POST;
|
||||
for (PostRow edit : findEdits(c, row.bchName, row.blockNumber, row.blockHash, editType)) {
|
||||
ChannelsReadSupport.TextInfo et = ChannelsReadSupport.parseTextAndTime(edit.blockBytes);
|
||||
Net_GetChannelMessages_Response.VersionItem v = new Net_GetChannelMessages_Response.VersionItem();
|
||||
|
||||
+62
-3
@@ -128,17 +128,26 @@ public class Net_GetPersonalDiary_Handler implements JsonMessageHandler {
|
||||
item.setAuthorLogin(rs.getString("login"));
|
||||
item.setAuthorBlockchainName(rs.getString("bch_name"));
|
||||
item.setCreatedAtMs(entry.timestamp * 1000L);
|
||||
item.setText(statusBody.message == null ? "" : statusBody.message);
|
||||
item.setLikesCount(0);
|
||||
item.setLikedByMe(false);
|
||||
item.setRepliesCount(0);
|
||||
item.setRatingsCount(0);
|
||||
item.setVersionsTotal(1);
|
||||
item.setVersions(new ArrayList<>());
|
||||
item.setTargetBlockchainName(statusBody.toBchName());
|
||||
item.setTargetBlockNumber(statusBody.toBlockGlobalNumber());
|
||||
item.setTargetBlockHash(ChannelsReadSupport.toHex(statusBody.toBlockHashBytes()));
|
||||
|
||||
List<Net_GetChannelMessages_Response.VersionItem> versions = loadVersionsForDiaryItem(
|
||||
c,
|
||||
rs.getString("bch_name"),
|
||||
rs.getInt("block_number"),
|
||||
rs.getBytes("block_hash"),
|
||||
statusBody.message == null ? "" : statusBody.message,
|
||||
entry.timestamp * 1000L
|
||||
);
|
||||
item.setVersions(versions);
|
||||
item.setVersionsTotal(versions.size());
|
||||
item.setText(versions.get(versions.size() - 1).getText());
|
||||
|
||||
fillTargetDetails(c, item, statusBody.toBchName(), statusBody.toBlockGlobalNumber(), statusBody.toBlockHashBytes());
|
||||
out.add(item);
|
||||
}
|
||||
@@ -147,6 +156,56 @@ public class Net_GetPersonalDiary_Handler implements JsonMessageHandler {
|
||||
return out;
|
||||
}
|
||||
|
||||
private List<Net_GetChannelMessages_Response.VersionItem> loadVersionsForDiaryItem(Connection c,
|
||||
String ownerBch,
|
||||
int originalBlockNumber,
|
||||
byte[] originalBlockHash,
|
||||
String originalText,
|
||||
long originalCreatedAtMs) throws Exception {
|
||||
List<Net_GetChannelMessages_Response.VersionItem> versions = new ArrayList<>();
|
||||
|
||||
Net_GetChannelMessages_Response.VersionItem first = new Net_GetChannelMessages_Response.VersionItem();
|
||||
first.setVersionIndex(1);
|
||||
first.setBlockNumber(originalBlockNumber);
|
||||
first.setBlockHash(ChannelsReadSupport.toHex(originalBlockHash));
|
||||
first.setText(originalText == null ? "" : originalText);
|
||||
first.setCreatedAtMs(originalCreatedAtMs);
|
||||
versions.add(first);
|
||||
|
||||
try (PreparedStatement ps = c.prepareStatement("""
|
||||
SELECT block_number, block_hash, block_bytes
|
||||
FROM blocks
|
||||
WHERE bch_name = ?
|
||||
AND msg_type = ?
|
||||
AND msg_sub_type = ?
|
||||
AND to_block_number = ?
|
||||
AND to_block_hash = ?
|
||||
AND (to_bch_name = ? OR to_bch_name IS NULL OR to_bch_name = '')
|
||||
ORDER BY block_number ASC
|
||||
""")) {
|
||||
ps.setString(1, ownerBch);
|
||||
ps.setInt(2, ChannelsReadSupport.MSG_TYPE_TEXT);
|
||||
ps.setInt(3, shine.db.MsgSubType.TEXT_EDIT_REPLY);
|
||||
ps.setInt(4, originalBlockNumber);
|
||||
ps.setBytes(5, originalBlockHash);
|
||||
ps.setString(6, ownerBch);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
ChannelsReadSupport.TextInfo editText = ChannelsReadSupport.parseTextAndTime(rs.getBytes("block_bytes"));
|
||||
Net_GetChannelMessages_Response.VersionItem item = new Net_GetChannelMessages_Response.VersionItem();
|
||||
item.setVersionIndex(versions.size() + 1);
|
||||
item.setBlockNumber(rs.getInt("block_number"));
|
||||
item.setBlockHash(ChannelsReadSupport.toHex(rs.getBytes("block_hash")));
|
||||
item.setText(editText.text);
|
||||
item.setCreatedAtMs(editText.createdAtMs);
|
||||
versions.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return versions;
|
||||
}
|
||||
|
||||
private void fillTargetDetails(Connection c,
|
||||
Net_GetChannelMessages_Response.MessageItem item,
|
||||
String targetBch,
|
||||
|
||||
Reference in New Issue
Block a user