SHA256
Починить сборку новой смены ключей
Исправлены compile blockers после доработки ротации ключей и DM.
This commit is contained in:
@@ -505,7 +505,7 @@ public final class SignedMessagesDAO {
|
||||
}
|
||||
}
|
||||
|
||||
private SignedMessageEntry getByMessageKey(Connection c, String messageKey) throws SQLException {
|
||||
private SignedMessageEntry getByMessageKey(Connection c, String messageKey) throws Exception {
|
||||
String sql = """
|
||||
SELECT
|
||||
message_key, base_key, target_login, from_login, to_login,
|
||||
|
||||
+41
-15
@@ -17,7 +17,9 @@ import shine.db.entities.UserNotificationEntry;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** Stores the complete ANS-104 DataItem and all derived SHiNE state atomically in PostgreSQL.
|
||||
* Local .bch/tmp/marker files are intentionally not used.
|
||||
@@ -60,7 +62,7 @@ public final class BlockchainWriter {
|
||||
|
||||
long nowMs = System.currentTimeMillis();
|
||||
byte[] rawDataItem = block.toBytes();
|
||||
List<String> counterChangedLogins = new ArrayList<>();
|
||||
Set<String> counterChangedLogins = new LinkedHashSet<>();
|
||||
try (Connection c = shine.db.DbController.getInstance().getConnection()) {
|
||||
c.setAutoCommit(false);
|
||||
try {
|
||||
@@ -89,7 +91,7 @@ public final class BlockchainWriter {
|
||||
channelVisibilityChanged = channelNameStateDAO.updateDeletedState(
|
||||
c, blockchainName, lineCode, false, 0L, null);
|
||||
}
|
||||
if (channelVisibilityChanged) refreshChannelVisibilityStats(c, blockchainName, lineCode);
|
||||
if (channelVisibilityChanged) counterChangedLogins.addAll(refreshChannelVisibilityStats(c, blockchainName, lineCode));
|
||||
}
|
||||
if (!replayMode && isPublicChannelPublication(msgType, msgSubType) && lineCode != null && lineCode > 0) {
|
||||
String channelName = channelReadStateDAO.resolvePublicChannelNameByRoot(c, blockchainName, lineCode);
|
||||
@@ -118,43 +120,67 @@ public final class BlockchainWriter {
|
||||
try { c.setAutoCommit(true); } catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
return counterChangedLogins;
|
||||
return new ArrayList<>(counterChangedLogins);
|
||||
}
|
||||
|
||||
private static void refreshChannelVisibilityStats(Connection c, String blockchainName, int lineCode) throws SQLException {
|
||||
private static List<String> refreshChannelVisibilityStats(Connection c, String blockchainName, int lineCode) throws SQLException {
|
||||
String sql = """
|
||||
SELECT owner_login FROM channel_names_state
|
||||
WHERE owner_bch_name=? AND channel_root_block_number=?
|
||||
SELECT owner_login, channel_root_block_hash
|
||||
FROM channel_names_state
|
||||
WHERE LOWER(owner_login)=LOWER(?) AND channel_root_block_number=?
|
||||
LIMIT 1
|
||||
""";
|
||||
String ownerLogin = null;
|
||||
byte[] rootHash = null;
|
||||
try (var ps = c.prepareStatement(sql)) {
|
||||
ps.setString(1, blockchainName);
|
||||
ps.setString(1, loginFromBlockchainName(blockchainName));
|
||||
ps.setInt(2, lineCode);
|
||||
try (var rs = ps.executeQuery()) { if (rs.next()) ownerLogin = rs.getString(1); }
|
||||
try (var rs = ps.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
ownerLogin = rs.getString("owner_login");
|
||||
rootHash = rs.getBytes("channel_root_block_hash");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ownerLogin == null || ownerLogin.isBlank()) return;
|
||||
if (ownerLogin == null || ownerLogin.isBlank() || rootHash == null) return List.of();
|
||||
|
||||
Set<String> affected = new LinkedHashSet<>();
|
||||
affected.add(ownerLogin);
|
||||
try (var ps = c.prepareStatement("SELECT shine_refresh_user_stats(?)")) {
|
||||
ps.setString(1, ownerLogin);
|
||||
ps.execute();
|
||||
}
|
||||
|
||||
String followersSql = """
|
||||
SELECT DISTINCT cs.login
|
||||
FROM connections_state cs
|
||||
JOIN channel_names_state cn
|
||||
ON LOWER(cn.owner_login)=LOWER(cs.to_login)
|
||||
AND cn.channel_root_block_number=cs.to_block_number
|
||||
AND cn.channel_root_block_hash=cs.to_block_hash
|
||||
WHERE cs.rel_type=? AND LOWER(cn.owner_login)=LOWER(?) AND cn.channel_root_block_number=?
|
||||
WHERE cs.rel_type=?
|
||||
AND LOWER(cs.to_login)=LOWER(?)
|
||||
AND cs.to_block_number=?
|
||||
AND cs.to_block_hash=?
|
||||
""";
|
||||
try (var ps = c.prepareStatement(followersSql)) {
|
||||
ps.setInt(1, MsgSubType.CONNECTION_FOLLOW);
|
||||
ps.setString(2, ownerLogin);
|
||||
ps.setInt(3, lineCode);
|
||||
ps.setBytes(4, rootHash);
|
||||
try (var rs = ps.executeQuery(); var refresh = c.prepareStatement("SELECT shine_refresh_user_stats(?)")) {
|
||||
while (rs.next()) { refresh.setString(1, rs.getString(1)); refresh.execute(); }
|
||||
while (rs.next()) {
|
||||
String follower = rs.getString(1);
|
||||
if (follower == null || follower.isBlank()) continue;
|
||||
refresh.setString(1, follower);
|
||||
refresh.execute();
|
||||
affected.add(follower);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(affected);
|
||||
}
|
||||
|
||||
private static String loginFromBlockchainName(String blockchainName) {
|
||||
if (blockchainName == null) return "";
|
||||
int dash = blockchainName.lastIndexOf('-');
|
||||
return dash > 0 ? blockchainName.substring(0, dash) : blockchainName;
|
||||
}
|
||||
|
||||
private static boolean isPublicChannelPublication(int msgType, int msgSubType) {
|
||||
|
||||
Reference in New Issue
Block a user