SHA256
Промежуточно: синхронизировать регистр логинов
This commit is contained in:
@@ -79,12 +79,12 @@ public final class HeaderBody implements BodyRecord {
|
||||
if ((subType & 0xFFFF) != 0) throw new IllegalArgumentException("HeaderBody subType must be 0");
|
||||
if (login == null || login.isBlank()) throw new IllegalArgumentException("Login is blank");
|
||||
byte[] loginUtf8 = login.getBytes(StandardCharsets.UTF_8);
|
||||
// Legacy login remains valid; new registration uses a canonical full login@namespace.
|
||||
// This changes only validation, not the serialized HEADER body or signature format.
|
||||
// В HEADER хранится неизменяемое написание зарегистрированного login@namespace.
|
||||
// Namespace остаётся lowercase, регистр локальной части сохраняется байт-в-байт.
|
||||
boolean legacyLogin = login.matches("^[A-Za-z0-9_]+$");
|
||||
boolean namespacedLogin = loginUtf8.length <= 30 && login.matches("^[a-z0-9_]+@[a-z0-9_]+$");
|
||||
boolean namespacedLogin = loginUtf8.length <= 30 && login.matches("^[A-Za-z0-9_]+@[a-z0-9_]+$");
|
||||
if (!legacyLogin && !namespacedLogin) {
|
||||
throw new IllegalArgumentException("Login must be legacy [A-Za-z0-9_]+ or canonical login@namespace (max 30 bytes)");
|
||||
throw new IllegalArgumentException("Login must be legacy [A-Za-z0-9_]+ or registered-case login@namespace (max 30 bytes)");
|
||||
}
|
||||
if (loginUtf8.length == 0 || loginUtf8.length > 255) throw new IllegalArgumentException("Login utf8 len must be 1..255");
|
||||
requireNonZeroKey(initialBlockchainKey32);
|
||||
|
||||
+17
-2
@@ -100,7 +100,7 @@ final class TargetLoginFormatTest {
|
||||
|
||||
@Test
|
||||
void namespacedHeaderRoundTripAcceptsPaidAndFreeUsers() {
|
||||
for (String login : new String[]{"alice@free", "alice@shine", "a_b@free", "abcdefghijklmnopqrstuvwxy@free"}) {
|
||||
for (String login : new String[]{"alice@free", "AlexSmith@shine", "a_B@free", "abcdefghijklmnopqrstuvwxy@free"}) {
|
||||
HeaderBody source = new HeaderBody(login, INITIAL_KEY);
|
||||
HeaderBody parsed = new HeaderBody(HeaderBody.SUBTYPE_COMPAT, HeaderBody.VER, source.toBytes()).check();
|
||||
assertEquals(login, parsed.login);
|
||||
@@ -110,11 +110,26 @@ final class TargetLoginFormatTest {
|
||||
|
||||
@Test
|
||||
void namespacedHeaderRejectsMalformedOrOversizedLogin() {
|
||||
for (String login : new String[]{"alice@", "@shine", "alice@@free", "Alice@free", "alice@FREE", "alice.free@shine", "abcdefghijklmnopqrstuvwxyz@free"}) {
|
||||
for (String login : new String[]{"alice@", "@shine", "alice@@free", "alice@FREE", "alice.free@shine", "abcdefghijklmnopqrstuvwxyz@free"}) {
|
||||
assertThrows(IllegalArgumentException.class, () -> new HeaderBody(login, INITIAL_KEY), login);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void signedReferencesPreserveArbitraryLoginCaseWithoutServerSideCaseEnforcement() {
|
||||
// Адресация не зависит от регистра, но блок сохраняет выбранные автором байты.
|
||||
for (String login : new String[]{"AlexSmith@shine", "alexsmith@shine"}) {
|
||||
TextReplyBody reply = new TextReplyBody(MsgSubType.TEXT_REPLY, login, 1, 42, HASH, "тест");
|
||||
assertEquals(login, new TextReplyBody(MsgSubType.TEXT_REPLY, TextReplyBody.VER, reply.toBytes()).check().toLogin());
|
||||
|
||||
ReactionBody like = new ReactionBody(MsgSubType.REACTION_LIKE, login, 1, 42, HASH);
|
||||
assertEquals(login, new ReactionBody(MsgSubType.REACTION_LIKE, ReactionBody.VER, like.toBytes()).check().toLogin());
|
||||
|
||||
ConnectionBody follow = new ConnectionBody(0, HASH, 1, MsgSubType.CONNECTION_FOLLOW, login, 1, 0, HASH);
|
||||
assertEquals(login, new ConnectionBody(MsgSubType.CONNECTION_FOLLOW, ConnectionBody.VER, follow.toBytes()).check().toLogin());
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] hash(int seed) {
|
||||
byte[] out = new byte[32];
|
||||
Arrays.fill(out, (byte) seed);
|
||||
|
||||
@@ -27,6 +27,7 @@ public final class DatabaseInitializer {
|
||||
public static final int SCHEMA_VERSION_34 = 34;
|
||||
public static final int SCHEMA_VERSION_35 = 35;
|
||||
public static final int SCHEMA_VERSION_36 = 36;
|
||||
public static final int SCHEMA_VERSION_37 = 37;
|
||||
public static final String POSTGRES_SCHEMA_RESOURCE = "postgres/schema_v1.sql";
|
||||
public static final String POSTGRES_MIGRATION_V31_RESOURCE = "postgres/migration_v31.sql";
|
||||
public static final String POSTGRES_MIGRATION_V32_RESOURCE = "postgres/migration_v32.sql";
|
||||
@@ -34,6 +35,7 @@ public final class DatabaseInitializer {
|
||||
public static final String POSTGRES_MIGRATION_V34_RESOURCE = "postgres/migration_v34.sql";
|
||||
public static final String POSTGRES_MIGRATION_V35_RESOURCE = "postgres/migration_v35.sql";
|
||||
public static final String POSTGRES_MIGRATION_V36_RESOURCE = "postgres/migration_v36.sql";
|
||||
public static final String POSTGRES_MIGRATION_V37_RESOURCE = "postgres/migration_v37.sql";
|
||||
|
||||
private DatabaseInitializer() {}
|
||||
|
||||
@@ -149,9 +151,13 @@ public final class DatabaseInitializer {
|
||||
runSqlScript(conn, POSTGRES_MIGRATION_V36_RESOURCE);
|
||||
currentVersion = readCurrentSchemaVersion(conn);
|
||||
}
|
||||
if (currentVersion != SCHEMA_VERSION_36) {
|
||||
if (currentVersion == SCHEMA_VERSION_36) {
|
||||
runSqlScript(conn, POSTGRES_MIGRATION_V37_RESOURCE);
|
||||
currentVersion = readCurrentSchemaVersion(conn);
|
||||
}
|
||||
if (currentVersion != SCHEMA_VERSION_37) {
|
||||
throw new SQLException(
|
||||
"Unsupported SHiNE DB v2 schema version: expected 36, found " + currentVersion);
|
||||
"Unsupported SHiNE DB v2 schema version: expected 37, found " + currentVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
-- v37: оригинальный регистр имени фиксируется при первой регистрации.
|
||||
-- Нормализованное имя остаётся единственным ключом уникальности.
|
||||
BEGIN;
|
||||
|
||||
CREATE OR REPLACE FUNCTION shine_identity_login_immutable()
|
||||
RETURNS TRIGGER LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
IF TG_OP = 'UPDATE' AND (NEW.login IS DISTINCT FROM OLD.login
|
||||
OR NEW.normalized_login IS DISTINCT FROM OLD.normalized_login) THEN
|
||||
RAISE EXCEPTION 'Registered login spelling is immutable: %', OLD.login;
|
||||
END IF;
|
||||
IF NEW.normalized_login IS DISTINCT FROM lower(btrim(NEW.login)) THEN
|
||||
RAISE EXCEPTION 'normalized_login must match registered login: %', NEW.login;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END $$;
|
||||
|
||||
DROP TRIGGER IF EXISTS trg_identity_login_immutable ON user_identity_current;
|
||||
CREATE TRIGGER trg_identity_login_immutable
|
||||
BEFORE INSERT OR UPDATE ON user_identity_current
|
||||
FOR EACH ROW EXECUTE FUNCTION shine_identity_login_immutable();
|
||||
|
||||
-- FREE_CERT -> Solana: имя должно совпадать побайтно, включая регистр.
|
||||
-- Источником имени остаётся первая регистрация, а не очередная синхронизация.
|
||||
CREATE OR REPLACE FUNCTION shine_sync_identity_from_solana()
|
||||
RETURNS TRIGGER LANGUAGE plpgsql AS $$
|
||||
DECLARE old_user user_identity_current%ROWTYPE;
|
||||
BEGIN
|
||||
IF TG_OP = 'INSERT' AND EXISTS (
|
||||
SELECT 1 FROM solana_user_pda_current prior
|
||||
WHERE prior.pda_address = NEW.pda_address AND prior.record_number > NEW.record_number
|
||||
) THEN
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
SELECT * INTO old_user FROM user_identity_current
|
||||
WHERE normalized_login = NEW.normalized_login FOR UPDATE;
|
||||
IF FOUND AND old_user.login <> NEW.login THEN
|
||||
RAISE EXCEPTION 'Registered login case mismatch: % vs %', old_user.login, NEW.login;
|
||||
END IF;
|
||||
IF FOUND AND old_user.registration_status = 'FREE_CERT' AND
|
||||
(old_user.root_key <> NEW.root_key OR old_user.client_key <> NEW.client_key OR old_user.blockchain_key <> NEW.blockchain_key) THEN
|
||||
RAISE EXCEPTION 'Free certificate keys differ from Solana upgrade for %', NEW.login;
|
||||
END IF;
|
||||
IF FOUND AND old_user.solana_pda_address IS NOT NULL AND old_user.solana_pda_address <> NEW.pda_address THEN
|
||||
RAISE EXCEPTION 'Duplicate on-chain identity for %', NEW.login;
|
||||
END IF;
|
||||
INSERT INTO user_identity_current (
|
||||
login, normalized_login, namespace, registration_source, registration_status,
|
||||
solana_pda_address, free_data_item_id, root_key, client_key, blockchain_key,
|
||||
blockchain_name, is_server, registered_at_ms, updated_at_ms)
|
||||
VALUES (NEW.login, NEW.normalized_login,
|
||||
CASE WHEN position('@' in NEW.login) > 0 THEN split_part(NEW.login,'@',2) ELSE NULL END,
|
||||
'SOLANA', 'PAID',
|
||||
NEW.pda_address, old_user.free_data_item_id, NEW.root_key, NEW.client_key,
|
||||
NEW.blockchain_key, NEW.blockchain_name, NEW.is_server,
|
||||
COALESCE(old_user.registered_at_ms, NEW.created_at_ms), NEW.updated_at_ms)
|
||||
ON CONFLICT (login) DO UPDATE SET
|
||||
registration_source='SOLANA',
|
||||
registration_status=EXCLUDED.registration_status,
|
||||
solana_pda_address=EXCLUDED.solana_pda_address,
|
||||
root_key=EXCLUDED.root_key, client_key=EXCLUDED.client_key,
|
||||
blockchain_key=EXCLUDED.blockchain_key, blockchain_name=EXCLUDED.blockchain_name,
|
||||
is_server=EXCLUDED.is_server, updated_at_ms=EXCLUDED.updated_at_ms;
|
||||
RETURN NEW;
|
||||
END $$;
|
||||
|
||||
UPDATE db_schema_version SET schema_version = 37,
|
||||
updated_at_ms = CAST(EXTRACT(EPOCH FROM clock_timestamp()) * 1000 AS BIGINT)
|
||||
WHERE id = 1;
|
||||
COMMIT;
|
||||
+13
-2
@@ -205,6 +205,8 @@ public final class Net_AddBlock_Handler implements JsonMessageHandler {
|
||||
case "bad_type_tag" -> "Некорректный индексный t-тег ANS-104";
|
||||
case "bad_channel_tag" -> "Некорректный тег канала ANS-104";
|
||||
case "bad_block_body" -> "Некорректное тело блока";
|
||||
case "header_login_mismatch" -> "HEADER должен содержать имя точно в регистре регистрации";
|
||||
case "header_identity_lookup_failed" -> "Не удалось проверить регистрационное имя HEADER";
|
||||
case "bad_channel_name" -> "Некорректное название канала";
|
||||
case "bad_block_number" -> "Некорректный номер блока";
|
||||
case "req_global_mismatch" -> "Номер блока в запросе не совпадает с номером в блоке";
|
||||
@@ -385,8 +387,17 @@ public final class Net_AddBlock_Handler implements JsonMessageHandler {
|
||||
if (!(block.body instanceof HeaderBody headerBody)) {
|
||||
return new AddBlockResult(WireCodes.Status.BAD_REQUEST, "header_required_as_block_zero", serverLastNum, serverLastHashHex);
|
||||
}
|
||||
if (!login.equals(headerBody.login)) {
|
||||
return new AddBlockResult(WireCodes.Status.BAD_REQUEST, "header_login_mismatch", serverLastNum, serverLastHashHex);
|
||||
// HEADER фиксирует написание из регистрационной записи, а не lower-case имя цепочки.
|
||||
// Проверка точная: другой регистр не может создать альтернативное "официальное" имя.
|
||||
try {
|
||||
CurrentUserEntry registeredOwner = currentUsersDAO.getByLogin(login);
|
||||
if (registeredOwner == null || !headerBody.login.equals(registeredOwner.getLogin())
|
||||
|| !login.equalsIgnoreCase(registeredOwner.getLogin())) {
|
||||
return new AddBlockResult(WireCodes.Status.BAD_REQUEST, "header_login_mismatch", serverLastNum, serverLastHashHex);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("AddBlock: cannot verify registered HEADER login for {}", blockchainName, e);
|
||||
return new AddBlockResult(WireCodes.Status.INTERNAL_ERROR, "header_identity_lookup_failed", serverLastNum, serverLastHashHex);
|
||||
}
|
||||
} else if (block.body instanceof HeaderBody) {
|
||||
return new AddBlockResult(WireCodes.Status.BAD_REQUEST, "header_must_be_block_zero", serverLastNum, serverLastHashHex);
|
||||
|
||||
+15
@@ -16,6 +16,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Locale;
|
||||
|
||||
final class ChannelsReadSupport {
|
||||
static final int MSG_TYPE_TEXT = 1;
|
||||
@@ -39,6 +41,19 @@ final class ChannelsReadSupport {
|
||||
}
|
||||
}
|
||||
|
||||
// Пользовательское отображение — из реестра, не из normalized blocks.login.
|
||||
// Кэш ограничен временем одного ответа и не требует дополнительных запросов на каждый пост.
|
||||
static String officialLogin(Connection c, Map<String, String> cache, String raw) throws SQLException {
|
||||
if (raw == null || raw.isBlank()) return raw;
|
||||
String key = raw.trim().toLowerCase(Locale.ROOT);
|
||||
String value = cache.get(key);
|
||||
if (value != null) return value;
|
||||
value = canonicalLogin(c, raw);
|
||||
if (value == null || value.isBlank()) value = raw;
|
||||
cache.put(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
static ChannelMeta detectChannelMeta(Connection c, String ownerBch, int rootNumber) throws SQLException {
|
||||
ChannelMeta meta = new ChannelMeta();
|
||||
meta.channelTypeVersion = CreateChannelBody.CHANNEL_TYPE_VERSION_DEFAULT & 0xFFFF;
|
||||
|
||||
+6
-3
@@ -20,6 +20,8 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Net_GetChannelMessages_Handler implements JsonMessageHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(Net_GetChannelMessages_Handler.class);
|
||||
@@ -44,6 +46,7 @@ public class Net_GetChannelMessages_Handler implements JsonMessageHandler {
|
||||
boolean asc = req.getSort() == null || !"desc".equalsIgnoreCase(req.getSort());
|
||||
|
||||
try (Connection c = DbController.getInstance().getConnection()) {
|
||||
Map<String, String> officialLogins = new HashMap<>();
|
||||
String viewerLogin = ctx != null ? ctx.getLogin() : null;
|
||||
if (viewerLogin == null || viewerLogin.isBlank()) {
|
||||
viewerLogin = ChannelsReadSupport.canonicalLogin(c, req.getLogin());
|
||||
@@ -58,7 +61,7 @@ public class Net_GetChannelMessages_Handler implements JsonMessageHandler {
|
||||
|
||||
Net_GetChannelMessages_Response.Channel channel = new Net_GetChannelMessages_Response.Channel();
|
||||
channel.setOwnerBlockchainName(ownerBch);
|
||||
channel.setOwnerLogin(BlockchainNameUtil.loginFromBlockchainName(ownerBch));
|
||||
channel.setOwnerLogin(ChannelsReadSupport.officialLogin(c, officialLogins, BlockchainNameUtil.loginFromBlockchainName(ownerBch)));
|
||||
ChannelsReadSupport.ChannelMeta meta = ChannelsReadSupport.detectChannelMeta(c, ownerBch, lineCode);
|
||||
channel.setChannelName(meta.channelName);
|
||||
channel.setDisplayName(meta.displayName == null || meta.displayName.isBlank() ? meta.channelName : meta.displayName);
|
||||
@@ -88,7 +91,7 @@ public class Net_GetChannelMessages_Handler implements JsonMessageHandler {
|
||||
eventRef.setBlockNumber(event.blockNumber);
|
||||
eventRef.setBlockHash(ChannelsReadSupport.toHex(event.blockHash));
|
||||
outEvent.setMessageRef(eventRef);
|
||||
outEvent.setAuthorLogin(event.login);
|
||||
outEvent.setAuthorLogin(ChannelsReadSupport.officialLogin(c, officialLogins, event.login));
|
||||
outEvent.setAuthorBlockchainName(event.bchName);
|
||||
outEvent.setLineStep(event.lineStep);
|
||||
outEvent.setCreatedAtMs(event.createdAtMs);
|
||||
@@ -133,7 +136,7 @@ public class Net_GetChannelMessages_Handler implements JsonMessageHandler {
|
||||
msgRef.setBlockHash(ChannelsReadSupport.toHex(post.blockHash));
|
||||
item.setMessageRef(msgRef);
|
||||
item.setMsgSubType(post.msgSubType);
|
||||
item.setAuthorLogin(post.login);
|
||||
item.setAuthorLogin(ChannelsReadSupport.officialLogin(c, officialLogins, post.login));
|
||||
item.setAuthorBlockchainName(post.bchName);
|
||||
item.setLineStep(post.thisLineNumber);
|
||||
item.setTargetBlockchainName(post.toBchName);
|
||||
|
||||
+11
-8
@@ -21,6 +21,8 @@ import java.util.Comparator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(Net_GetMessageThread_Handler.class);
|
||||
@@ -37,6 +39,7 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
int childLimit = req.getLimitChildrenPerNode() == null ? 50 : Math.max(1, req.getLimitChildrenPerNode());
|
||||
|
||||
try (Connection c = DbController.getInstance().getConnection()) {
|
||||
Map<String, String> officialLogins = new HashMap<>();
|
||||
String viewerLogin = ctx != null ? ctx.getLogin() : null;
|
||||
if (viewerLogin == null || viewerLogin.isBlank()) {
|
||||
viewerLogin = ChannelsReadSupport.canonicalLogin(c, req.getLogin());
|
||||
@@ -51,7 +54,7 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
resp.setRequestId(req.getRequestId());
|
||||
resp.setStatus(WireCodes.Status.OK);
|
||||
|
||||
resp.setFocus(toNode(c, focusRow, viewerLogin));
|
||||
resp.setFocus(toNode(c, focusRow, viewerLogin, officialLogins));
|
||||
|
||||
List<Net_GetMessageThread_Response.MessageNode> ancestors = new ArrayList<>();
|
||||
PostRow cur = focusRow;
|
||||
@@ -68,12 +71,12 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
parent = findByNumber(c, cur.toBchName, cur.toBlockNumber);
|
||||
}
|
||||
if (parent == null) break;
|
||||
ancestors.add(0, toNode(c, parent, viewerLogin));
|
||||
ancestors.add(0, toNode(c, parent, viewerLogin, officialLogins));
|
||||
cur = parent;
|
||||
}
|
||||
resp.setAncestors(ancestors);
|
||||
|
||||
resp.setDescendants(loadChildren(c, focusRow, depthDown, childLimit, viewerLogin));
|
||||
resp.setDescendants(loadChildren(c, focusRow, depthDown, childLimit, viewerLogin, officialLogins));
|
||||
return resp;
|
||||
} catch (Exception e) {
|
||||
log.error("GetMessageThread failed", e);
|
||||
@@ -97,14 +100,14 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Net_GetMessageThread_Response.MessageNodeTree> loadChildren(Connection c, PostRow parent, int depthDown, int childLimit, String viewerLogin) throws Exception {
|
||||
private List<Net_GetMessageThread_Response.MessageNodeTree> loadChildren(Connection c, PostRow parent, int depthDown, int childLimit, String viewerLogin, Map<String, String> officialLogins) throws Exception {
|
||||
if (depthDown <= 0) return List.of();
|
||||
List<PostRow> replies = findRepliesAndRatings(c, parent.bchName, parent.blockNumber, parent.blockHash, childLimit);
|
||||
List<Net_GetMessageThread_Response.MessageNodeTree> out = new ArrayList<>();
|
||||
for (PostRow row : replies) {
|
||||
Net_GetMessageThread_Response.MessageNodeTree t = new Net_GetMessageThread_Response.MessageNodeTree();
|
||||
t.setNode(toNode(c, row, viewerLogin));
|
||||
t.setChildren(loadChildren(c, row, depthDown - 1, childLimit, viewerLogin));
|
||||
t.setNode(toNode(c, row, viewerLogin, officialLogins));
|
||||
t.setChildren(loadChildren(c, row, depthDown - 1, childLimit, viewerLogin, officialLogins));
|
||||
out.add(t);
|
||||
}
|
||||
return out;
|
||||
@@ -233,14 +236,14 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
return row;
|
||||
}
|
||||
|
||||
private Net_GetMessageThread_Response.MessageNode toNode(Connection c, PostRow row, String viewerLogin) throws Exception {
|
||||
private Net_GetMessageThread_Response.MessageNode toNode(Connection c, PostRow row, String viewerLogin, Map<String, String> officialLogins) throws Exception {
|
||||
Net_GetMessageThread_Response.MessageNode node = new Net_GetMessageThread_Response.MessageNode();
|
||||
Net_GetChannelMessages_Response.BlockRef ref = new Net_GetChannelMessages_Response.BlockRef();
|
||||
ref.setBlockNumber(row.blockNumber);
|
||||
ref.setBlockHash(ChannelsReadSupport.toHex(row.blockHash));
|
||||
node.setMessageRef(ref);
|
||||
node.setMsgSubType(row.msgSubType);
|
||||
node.setAuthorLogin(row.login);
|
||||
node.setAuthorLogin(ChannelsReadSupport.officialLogin(c, officialLogins, row.login));
|
||||
node.setAuthorBlockchainName(row.bchName);
|
||||
node.setLineStep(row.thisLineNumber);
|
||||
node.setTargetBlockchainName(row.toBchName);
|
||||
|
||||
+5
-2
@@ -19,6 +19,8 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Net_ListSubscriptionsFeed_Handler implements JsonMessageHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(Net_ListSubscriptionsFeed_Handler.class);
|
||||
@@ -59,11 +61,12 @@ public class Net_ListSubscriptionsFeed_Handler implements JsonMessageHandler {
|
||||
|
||||
private List<Net_ListSubscriptionsFeed_Response.ChannelSummary> buildSummaries(Connection c, String viewerLogin, List<ChannelKey> keys) throws Exception {
|
||||
List<Net_ListSubscriptionsFeed_Response.ChannelSummary> out = new ArrayList<>();
|
||||
Map<String, String> officialLogins = new HashMap<>();
|
||||
for (ChannelKey key : keys) {
|
||||
Net_ListSubscriptionsFeed_Response.ChannelSummary row = new Net_ListSubscriptionsFeed_Response.ChannelSummary();
|
||||
Net_ListSubscriptionsFeed_Response.ChannelRef channelRef = new Net_ListSubscriptionsFeed_Response.ChannelRef();
|
||||
ChannelsReadSupport.ChannelMeta meta = ChannelsReadSupport.detectChannelMeta(c, key.ownerBch, key.rootNumber);
|
||||
channelRef.setOwnerLogin(key.ownerLogin);
|
||||
channelRef.setOwnerLogin(ChannelsReadSupport.officialLogin(c, officialLogins, key.ownerLogin));
|
||||
channelRef.setOwnerBlockchainName(key.ownerBch);
|
||||
channelRef.setChannelName(meta.channelName);
|
||||
channelRef.setDisplayName(meta.displayName == null || meta.displayName.isBlank() ? meta.channelName : meta.displayName);
|
||||
@@ -108,7 +111,7 @@ public class Net_ListSubscriptionsFeed_Handler implements JsonMessageHandler {
|
||||
lm.setMessageRef(msgRef);
|
||||
lm.setText(textInfo.text);
|
||||
lm.setCreatedAtMs(textInfo.createdAtMs);
|
||||
lm.setAuthorLogin(actual.login);
|
||||
lm.setAuthorLogin(ChannelsReadSupport.officialLogin(c, officialLogins, actual.login));
|
||||
lm.setAuthorBlockchainName(actual.bchName);
|
||||
row.setLastMessage(lm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user