SHA256
Исправить регистр ключей и ответные связи
This commit is contained in:
+4
-1
@@ -124,7 +124,10 @@ public final class VerifiedFreeRegistrationImporter {
|
|||||||
last_block_number, last_block_hash, updated_at_ms)
|
last_block_number, last_block_hash, updated_at_ms)
|
||||||
VALUES (?, 1, ?, 0, 0, -1, ?, ?)
|
VALUES (?, 1, ?, 0, 0, -1, ?, ?)
|
||||||
""")) {
|
""")) {
|
||||||
insert.setString(1, login);
|
// blockchain_state — техническая проекция chain: её ключ
|
||||||
|
// совпадает с normalized_login и blockchain_name, а не с
|
||||||
|
// отображаемым написанием login в сертификате.
|
||||||
|
insert.setString(1, login.toLowerCase(java.util.Locale.ROOT));
|
||||||
// blockchain_state — runtime-слой: его ключ всегда Base64(32),
|
// blockchain_state — runtime-слой: его ключ всегда Base64(32),
|
||||||
// как и у пользователей, импортированных из Solana PDA.
|
// как и у пользователей, импортированных из Solana PDA.
|
||||||
insert.setString(2, Base64.getEncoder().encodeToString(cert.blockchainKey()));
|
insert.setString(2, Base64.getEncoder().encodeToString(cert.blockchainKey()));
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public final class DatabaseInitializer {
|
|||||||
public static final int SCHEMA_VERSION_40 = 40;
|
public static final int SCHEMA_VERSION_40 = 40;
|
||||||
public static final int SCHEMA_VERSION_41 = 41;
|
public static final int SCHEMA_VERSION_41 = 41;
|
||||||
public static final int SCHEMA_VERSION_42 = 42;
|
public static final int SCHEMA_VERSION_42 = 42;
|
||||||
|
public static final int SCHEMA_VERSION_43 = 43;
|
||||||
|
public static final int SCHEMA_VERSION_44 = 44;
|
||||||
public static final String POSTGRES_SCHEMA_RESOURCE = "postgres/schema_v1.sql";
|
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_V31_RESOURCE = "postgres/migration_v31.sql";
|
||||||
public static final String POSTGRES_MIGRATION_V32_RESOURCE = "postgres/migration_v32.sql";
|
public static final String POSTGRES_MIGRATION_V32_RESOURCE = "postgres/migration_v32.sql";
|
||||||
@@ -46,6 +48,8 @@ public final class DatabaseInitializer {
|
|||||||
public static final String POSTGRES_MIGRATION_V40_RESOURCE = "postgres/migration_v40.sql";
|
public static final String POSTGRES_MIGRATION_V40_RESOURCE = "postgres/migration_v40.sql";
|
||||||
public static final String POSTGRES_MIGRATION_V41_RESOURCE = "postgres/migration_v41.sql";
|
public static final String POSTGRES_MIGRATION_V41_RESOURCE = "postgres/migration_v41.sql";
|
||||||
public static final String POSTGRES_MIGRATION_V42_RESOURCE = "postgres/migration_v42.sql";
|
public static final String POSTGRES_MIGRATION_V42_RESOURCE = "postgres/migration_v42.sql";
|
||||||
|
public static final String POSTGRES_MIGRATION_V43_RESOURCE = "postgres/migration_v43.sql";
|
||||||
|
public static final String POSTGRES_MIGRATION_V44_RESOURCE = "postgres/migration_v44.sql";
|
||||||
|
|
||||||
private DatabaseInitializer() {}
|
private DatabaseInitializer() {}
|
||||||
|
|
||||||
@@ -185,9 +189,17 @@ public final class DatabaseInitializer {
|
|||||||
runSqlScript(conn, POSTGRES_MIGRATION_V42_RESOURCE);
|
runSqlScript(conn, POSTGRES_MIGRATION_V42_RESOURCE);
|
||||||
currentVersion = readCurrentSchemaVersion(conn);
|
currentVersion = readCurrentSchemaVersion(conn);
|
||||||
}
|
}
|
||||||
if (currentVersion != SCHEMA_VERSION_42) {
|
if (currentVersion == SCHEMA_VERSION_42) {
|
||||||
|
runSqlScript(conn, POSTGRES_MIGRATION_V43_RESOURCE);
|
||||||
|
currentVersion = readCurrentSchemaVersion(conn);
|
||||||
|
}
|
||||||
|
if (currentVersion == SCHEMA_VERSION_43) {
|
||||||
|
runSqlScript(conn, POSTGRES_MIGRATION_V44_RESOURCE);
|
||||||
|
currentVersion = readCurrentSchemaVersion(conn);
|
||||||
|
}
|
||||||
|
if (currentVersion != SCHEMA_VERSION_44) {
|
||||||
throw new SQLException(
|
throw new SQLException(
|
||||||
"Unsupported SHiNE DB v2 schema version: expected 42, found " + currentVersion);
|
"Unsupported SHiNE DB v2 schema version: expected 44, found " + currentVersion);
|
||||||
}
|
}
|
||||||
normalizeBlockchainStateKeysToBase64(conn);
|
normalizeBlockchainStateKeysToBase64(conn);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -10,6 +10,7 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class UserNotificationsStateDAO {
|
public final class UserNotificationsStateDAO {
|
||||||
private static volatile UserNotificationsStateDAO instance;
|
private static volatile UserNotificationsStateDAO instance;
|
||||||
@@ -45,7 +46,7 @@ public final class UserNotificationsStateDAO {
|
|||||||
""";
|
""";
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
ps.setString(i++, e.getOwnerLogin());
|
ps.setString(i++, normalizedLogin(e.getOwnerLogin()));
|
||||||
ps.setString(i++, e.getNotificationKind());
|
ps.setString(i++, e.getNotificationKind());
|
||||||
ps.setLong(i++, e.getCreatedAtMs());
|
ps.setLong(i++, e.getCreatedAtMs());
|
||||||
ps.setString(i++, e.getSourceLogin());
|
ps.setString(i++, e.getSourceLogin());
|
||||||
@@ -74,7 +75,7 @@ public final class UserNotificationsStateDAO {
|
|||||||
""";
|
""";
|
||||||
List<UserNotificationEntry> out = new ArrayList<>();
|
List<UserNotificationEntry> out = new ArrayList<>();
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, ownerLogin);
|
ps.setString(1, normalizedLogin(ownerLogin));
|
||||||
ps.setString(2, kind);
|
ps.setString(2, kind);
|
||||||
ps.setInt(3, Math.max(1, limit));
|
ps.setInt(3, Math.max(1, limit));
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
@@ -96,7 +97,7 @@ public final class UserNotificationsStateDAO {
|
|||||||
""";
|
""";
|
||||||
List<UserNotificationEntry> out = new ArrayList<>();
|
List<UserNotificationEntry> out = new ArrayList<>();
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, ownerLogin); ps.setString(2, kind); ps.setLong(3, Math.max(0, seenAtMs));
|
ps.setString(1, normalizedLogin(ownerLogin)); ps.setString(2, kind); ps.setLong(3, Math.max(0, seenAtMs));
|
||||||
ps.setLong(4, Math.max(0, cutoffMs));
|
ps.setLong(4, Math.max(0, cutoffMs));
|
||||||
try (ResultSet rs = ps.executeQuery()) { while (rs.next()) out.add(mapRow(rs)); }
|
try (ResultSet rs = ps.executeQuery()) { while (rs.next()) out.add(mapRow(rs)); }
|
||||||
}
|
}
|
||||||
@@ -106,7 +107,7 @@ public final class UserNotificationsStateDAO {
|
|||||||
public long countUnseen(Connection c, String ownerLogin, String kind, long seenAtMs) throws SQLException {
|
public long countUnseen(Connection c, String ownerLogin, String kind, long seenAtMs) throws SQLException {
|
||||||
String sql = "SELECT COUNT(*) FROM user_notifications_state WHERE owner_login = ? AND notification_kind = ? AND created_at_ms > ?";
|
String sql = "SELECT COUNT(*) FROM user_notifications_state WHERE owner_login = ? AND notification_kind = ? AND created_at_ms > ?";
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, ownerLogin); ps.setString(2, kind); ps.setLong(3, Math.max(0, seenAtMs));
|
ps.setString(1, normalizedLogin(ownerLogin)); ps.setString(2, kind); ps.setLong(3, Math.max(0, seenAtMs));
|
||||||
try (ResultSet rs = ps.executeQuery()) { return rs.next() ? rs.getLong(1) : 0L; }
|
try (ResultSet rs = ps.executeQuery()) { return rs.next() ? rs.getLong(1) : 0L; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,4 +130,12 @@ public final class UserNotificationsStateDAO {
|
|||||||
e.setSourceText(rs.getString("source_text"));
|
e.setSourceText(rs.getString("source_text"));
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* owner_login — технический FK на normalized_login. Исходный регистр остаётся
|
||||||
|
* в полях подписанного блока и в отображаемых source/target login.
|
||||||
|
*/
|
||||||
|
private static String normalizedLogin(String login) {
|
||||||
|
return login == null ? null : login.trim().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-3
@@ -1,6 +1,7 @@
|
|||||||
package shine.db.entities;
|
package shine.db.entities;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Агрегатная сущность текущего состояния блокчейна.
|
* Агрегатная сущность текущего состояния блокчейна.
|
||||||
@@ -42,14 +43,18 @@ public final class BlockchainStateEntry {
|
|||||||
if (dash <= 0 || blockchainName.length()-dash-1 != 3) throw new IllegalArgumentException("Bad blockchainName: "+blockchainName);
|
if (dash <= 0 || blockchainName.length()-dash-1 != 3) throw new IllegalArgumentException("Bad blockchainName: "+blockchainName);
|
||||||
int parsedFork=Integer.parseInt(blockchainName.substring(dash+1));
|
int parsedFork=Integer.parseInt(blockchainName.substring(dash+1));
|
||||||
if (parsedFork < 1 || parsedFork > 999) throw new IllegalArgumentException("forkNumber must be 1..999");
|
if (parsedFork < 1 || parsedFork > 999) throw new IllegalArgumentException("forkNumber must be 1..999");
|
||||||
this.login=blockchainName.substring(0,dash);
|
// Runtime-ключ цепочки всегда нормализован. Исходное написание
|
||||||
|
// зарегистрированного login хранится отдельно в user_identity_current.
|
||||||
|
this.login=blockchainName.substring(0,dash).trim().toLowerCase(Locale.ROOT);
|
||||||
this.forkNumber=parsedFork;
|
this.forkNumber=parsedFork;
|
||||||
}
|
}
|
||||||
public int getForkNumber() { return forkNumber; }
|
public int getForkNumber() { return forkNumber; }
|
||||||
public void setForkNumber(int forkNumber) { if (forkNumber < 1 || forkNumber > 999) throw new IllegalArgumentException("forkNumber must be 1..999"); this.forkNumber = forkNumber; }
|
public void setForkNumber(int forkNumber) { if (forkNumber < 1 || forkNumber > 999) throw new IllegalArgumentException("forkNumber must be 1..999"); this.forkNumber = forkNumber; }
|
||||||
|
|
||||||
public String getLogin() { return login; }
|
public String getLogin() { return login; }
|
||||||
public void setLogin(String login) { this.login = login; }
|
public void setLogin(String login) {
|
||||||
|
this.login = login == null ? null : login.trim().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
public String getBlockchainKey() { return blockchainKey; }
|
public String getBlockchainKey() { return blockchainKey; }
|
||||||
public void setBlockchainKey(String blockchainKey) { this.blockchainKey = blockchainKey; }
|
public void setBlockchainKey(String blockchainKey) { this.blockchainKey = blockchainKey; }
|
||||||
@@ -80,4 +85,4 @@ public final class BlockchainStateEntry {
|
|||||||
|
|
||||||
public long getUpdatedAtMs() { return updatedAtMs; }
|
public long getUpdatedAtMs() { return updatedAtMs; }
|
||||||
public void setUpdatedAtMs(long updatedAtMs) { this.updatedAtMs = updatedAtMs; }
|
public void setUpdatedAtMs(long updatedAtMs) { this.updatedAtMs = updatedAtMs; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
-- v43: runtime-идентичность blockchain_state совпадает с normalized_login.
|
||||||
|
-- Исходный регистр зарегистрированного имени остаётся в user_identity_current.login
|
||||||
|
-- и никогда не переписывает подписанные сертификаты или блоки.
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- blocks_store уже использует normalized_login. Временно снимаем составной FK,
|
||||||
|
-- чтобы привести родительские строки blockchain_state к тому же ключу.
|
||||||
|
ALTER TABLE blocks_store DROP CONSTRAINT IF EXISTS fk_blocks_physical_fork;
|
||||||
|
ALTER TABLE blockchain_state_store DROP CONSTRAINT IF EXISTS blockchain_state_login_fkey;
|
||||||
|
|
||||||
|
-- v36-совместимость подставляла display login, что несовместимо с blocks_store.
|
||||||
|
DROP TRIGGER IF EXISTS trg_canonical_identity_blockchain_state_store_login
|
||||||
|
ON blockchain_state_store;
|
||||||
|
|
||||||
|
UPDATE blockchain_state_store
|
||||||
|
SET login = LOWER(BTRIM(login))
|
||||||
|
WHERE login IS DISTINCT FROM LOWER(BTRIM(login));
|
||||||
|
|
||||||
|
ALTER TABLE blockchain_state_store
|
||||||
|
ADD CONSTRAINT blockchain_state_login_fkey
|
||||||
|
FOREIGN KEY (login) REFERENCES user_identity_current(normalized_login);
|
||||||
|
|
||||||
|
ALTER TABLE blocks_store
|
||||||
|
ADD CONSTRAINT fk_blocks_physical_fork
|
||||||
|
FOREIGN KEY (login, fork_number)
|
||||||
|
REFERENCES blockchain_state_store(login, fork_number);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION shine_normalize_blockchain_state_login()
|
||||||
|
RETURNS TRIGGER LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
NEW.login := LOWER(BTRIM(NEW.login));
|
||||||
|
RETURN NEW;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
CREATE TRIGGER trg_normalize_blockchain_state_login
|
||||||
|
BEFORE INSERT OR UPDATE OF login ON blockchain_state_store
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION shine_normalize_blockchain_state_login();
|
||||||
|
|
||||||
|
UPDATE db_schema_version
|
||||||
|
SET schema_version = 43,
|
||||||
|
updated_at_ms = CAST(EXTRACT(EPOCH FROM clock_timestamp()) * 1000 AS BIGINT)
|
||||||
|
WHERE id = 1;
|
||||||
|
COMMIT;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
-- v44: owner_login уведомлений — технический ключ normalized_login.
|
||||||
|
-- Исходный регистр остаётся в содержимом подписанных блоков и полях source/target.
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
UPDATE user_notifications_state
|
||||||
|
SET owner_login = LOWER(BTRIM(owner_login))
|
||||||
|
WHERE owner_login IS DISTINCT FROM LOWER(BTRIM(owner_login));
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS trg_canonical_identity_user_notifications_state_owner_login
|
||||||
|
ON user_notifications_state;
|
||||||
|
DROP TRIGGER IF EXISTS trg_normalize_user_notifications_state_owner_login
|
||||||
|
ON user_notifications_state;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION shine_normalize_user_notification_owner_login()
|
||||||
|
RETURNS TRIGGER LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
NEW.owner_login := LOWER(BTRIM(NEW.owner_login));
|
||||||
|
RETURN NEW;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
CREATE TRIGGER trg_normalize_user_notifications_state_owner_login
|
||||||
|
BEFORE INSERT OR UPDATE OF owner_login ON user_notifications_state
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION shine_normalize_user_notification_owner_login();
|
||||||
|
|
||||||
|
UPDATE db_schema_version
|
||||||
|
SET schema_version = 44,
|
||||||
|
updated_at_ms = CAST(EXTRACT(EPOCH FROM clock_timestamp()) * 1000 AS BIGINT)
|
||||||
|
WHERE id = 1;
|
||||||
|
COMMIT;
|
||||||
@@ -35,3 +35,9 @@ payload = identity_fields || inner_signature64 || email_sha256:32
|
|||||||
Детерминированные фикстуры: `shine-solana/shine/tests/fixtures/registration-v2.json` (в том числе ранее подписанный ANS-104 DataItem с историческим `App=test5591`, его ID и подписи). Этот вектор сохранён **исключительно для проверки криптографического формата**, он НЕ является актуальным тегом выпуска. Актуальный `App=test5592` проверяется выпуском нового сертификата через Java `FreeRegistrationCertificateV1Check`. Векторные ключи предназначены только для тестов. Java-подписание и проверка сертификата присутствуют в этапе 7; загрузка через Turbo и доверенный импорт — этап 8.
|
Детерминированные фикстуры: `shine-solana/shine/tests/fixtures/registration-v2.json` (в том числе ранее подписанный ANS-104 DataItem с историческим `App=test5591`, его ID и подписи). Этот вектор сохранён **исключительно для проверки криптографического формата**, он НЕ является актуальным тегом выпуска. Актуальный `App=test5592` проверяется выпуском нового сертификата через Java `FreeRegistrationCertificateV1Check`. Векторные ключи предназначены только для тестов. Java-подписание и проверка сертификата присутствуют в этапе 7; загрузка через Turbo и доверенный импорт — этап 8.
|
||||||
|
|
||||||
Адрес PDA при upgrade вычисляется от **ASCII lowercase** полного логина, но строка логина в сертификате, его подпись и поле `login` в PDA остаются в исходном регистре. Пароль/Argon2id также используют lowercase полного логина.
|
Адрес PDA при upgrade вычисляется от **ASCII lowercase** полного логина, но строка логина в сертификате, его подпись и поле `login` в PDA остаются в исходном регистре. Пароль/Argon2id также используют lowercase полного логина.
|
||||||
|
|
||||||
|
Исходное написание — это отображаемое зарегистрированное имя. Runtime-идентификаторы
|
||||||
|
(`normalized_login`, `blockchain_name`, ключи `blocks_store` и `blockchain_state_store`)
|
||||||
|
используют ASCII lowercase. Поэтому уже выпущенные сертификаты с заглавными буквами
|
||||||
|
остаются валидными: сервер не меняет их подписанные байты, а приводит к lowercase
|
||||||
|
только несигнатурные ключи хранения и поиска.
|
||||||
|
|||||||
@@ -2213,7 +2213,9 @@
|
|||||||
"text_066": "Subscribed",
|
"text_066": "Subscribed",
|
||||||
"text_067": "Subscribed.",
|
"text_067": "Subscribed.",
|
||||||
"text_070": "Signed.",
|
"text_070": "Signed.",
|
||||||
"text_071": "Category of notifications"
|
"text_071": "Category of notifications",
|
||||||
|
"text_072": "Add close friend in return",
|
||||||
|
"text_073": "You are close friends now"
|
||||||
},
|
},
|
||||||
"user_profile_list_view": {
|
"user_profile_list_view": {
|
||||||
"text_002": "Message",
|
"text_002": "Message",
|
||||||
|
|||||||
@@ -2346,7 +2346,9 @@
|
|||||||
"text_068": "Подписался",
|
"text_068": "Подписался",
|
||||||
"text_069": "Подписалась",
|
"text_069": "Подписалась",
|
||||||
"text_070": "Подписался(-ась)",
|
"text_070": "Подписался(-ась)",
|
||||||
"text_071": "Категория уведомлений"
|
"text_071": "Категория уведомлений",
|
||||||
|
"text_072": "Добавить в близкие друзья в ответ",
|
||||||
|
"text_073": "Теперь вы близкие друзья"
|
||||||
},
|
},
|
||||||
"user_profile_list_view": {
|
"user_profile_list_view": {
|
||||||
"text_001": "Список",
|
"text_001": "Список",
|
||||||
|
|||||||
@@ -57,6 +57,24 @@ function actionLabel(item, activeTab) {
|
|||||||
: eventActionLabel(item.sourceMsgSubType, gender);
|
: eventActionLabel(item.sourceMsgSubType, gender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reciprocalRelationKind(item) {
|
||||||
|
return Number(item?.connectionTypeCode ?? item?.sourceMsgSubType) === CONNECTION_CLOSE_FRIEND
|
||||||
|
? 'close_friend'
|
||||||
|
: 'friend';
|
||||||
|
}
|
||||||
|
|
||||||
|
function reciprocalRelationLabel(kind) {
|
||||||
|
return kind === 'close_friend'
|
||||||
|
? t('screens.notifications_view.text_072')
|
||||||
|
: t('screens.notifications_view.text_009');
|
||||||
|
}
|
||||||
|
|
||||||
|
function reciprocalRelationSuccessLabel(kind) {
|
||||||
|
return kind === 'close_friend'
|
||||||
|
? t('screens.notifications_view.text_073')
|
||||||
|
: t('screens.notifications_view.text_015');
|
||||||
|
}
|
||||||
|
|
||||||
export const pageMeta = { id: 'notifications-view', get title() { return t('screens.notifications_view.text_001'); } };
|
export const pageMeta = { id: 'notifications-view', get title() { return t('screens.notifications_view.text_001'); } };
|
||||||
|
|
||||||
function normalizeItem(item) {
|
function normalizeItem(item) {
|
||||||
@@ -192,10 +210,19 @@ function renderHead(item) {
|
|||||||
|| item.sourceLogin || t('screens.notifications_view.text_030');
|
|| item.sourceLogin || t('screens.notifications_view.text_030');
|
||||||
const head = document.createElement('div');
|
const head = document.createElement('div');
|
||||||
head.className = 'notification-card__head';
|
head.className = 'notification-card__head';
|
||||||
|
const identity = document.createElement('div');
|
||||||
|
identity.className = 'notification-card__identity';
|
||||||
const name = document.createElement('strong');
|
const name = document.createElement('strong');
|
||||||
name.className = 'notification-card__name';
|
name.className = 'notification-card__name';
|
||||||
name.textContent = fullName;
|
name.textContent = fullName;
|
||||||
head.append(name);
|
identity.append(name);
|
||||||
|
if (item.sourceLogin) {
|
||||||
|
const login = document.createElement('span');
|
||||||
|
login.className = 'notification-card__login';
|
||||||
|
login.textContent = item.sourceLogin;
|
||||||
|
identity.append(login);
|
||||||
|
}
|
||||||
|
head.append(identity);
|
||||||
const time = document.createElement('span');
|
const time = document.createElement('span');
|
||||||
time.className = 'notification-card__time';
|
time.className = 'notification-card__time';
|
||||||
time.textContent = formatListTime(item.createdAtMs);
|
time.textContent = formatListTime(item.createdAtMs);
|
||||||
@@ -301,8 +328,7 @@ function renderItem(item, activeTab, navigate) {
|
|||||||
function refreshItemRow(row, item, activeTab) {
|
function refreshItemRow(row, item, activeTab) {
|
||||||
if (!row?.isConnected) return;
|
if (!row?.isConnected) return;
|
||||||
row.querySelector('.notification-avatar')?.replaceWith(renderAvatar(item));
|
row.querySelector('.notification-avatar')?.replaceWith(renderAvatar(item));
|
||||||
const name = row.querySelector('.notification-card__name');
|
row.querySelector('.notification-card__head')?.replaceWith(renderHead(item));
|
||||||
if (name) name.textContent = renderHead(item).querySelector('.notification-card__name').textContent;
|
|
||||||
const action = row.querySelector('.notification-card__action');
|
const action = row.querySelector('.notification-card__action');
|
||||||
if (action && activeTab !== 'replies') action.textContent = actionLabel(item, activeTab);
|
if (action && activeTab !== 'replies') action.textContent = actionLabel(item, activeTab);
|
||||||
if (activeTab === 'replies' && item.engagement && !row.querySelector('.notification-engagement')) {
|
if (activeTab === 'replies' && item.engagement && !row.querySelector('.notification-engagement')) {
|
||||||
@@ -453,24 +479,25 @@ export function render({ navigate, chrome } = {}) {
|
|||||||
const row = rowByItem.get(item);
|
const row = rowByItem.get(item);
|
||||||
const body = row?.querySelector('.notification-card__body');
|
const body = row?.querySelector('.notification-card__body');
|
||||||
if (!body) continue;
|
if (!body) continue;
|
||||||
|
const kind = reciprocalRelationKind(item);
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.type = 'button';
|
button.type = 'button';
|
||||||
button.className = 'secondary-btn notification-card__answer';
|
button.className = 'secondary-btn notification-card__answer';
|
||||||
button.textContent = t('screens.notifications_view.text_009');
|
button.textContent = reciprocalRelationLabel(kind);
|
||||||
button.addEventListener('click', async (event) => {
|
button.addEventListener('click', async (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
button.textContent = t('screens.notifications_view.text_010');
|
button.textContent = t('screens.notifications_view.text_010');
|
||||||
try {
|
try {
|
||||||
await authService.setUserRelation({ login: self, toLogin: login, kind: 'friend', enabled: true, storagePwd: state.session.storagePwdInMemory });
|
await authService.setUserRelation({ login: self, toLogin: login, kind, enabled: true, storagePwd: state.session.storagePwdInMemory });
|
||||||
const done = document.createElement('span');
|
const done = document.createElement('span');
|
||||||
done.className = 'notification-card__answered';
|
done.className = 'notification-card__answered';
|
||||||
done.innerHTML = `${iconHtml('check')}<span>${th('screens.notifications_view.text_046')}</span>`;
|
done.innerHTML = `${iconHtml('check')}<span>${th(reciprocalRelationSuccessLabel(kind))}</span>`;
|
||||||
button.replaceWith(done);
|
button.replaceWith(done);
|
||||||
showToast(t('screens.notifications_view.text_015'));
|
showToast(reciprocalRelationSuccessLabel(kind));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
button.disabled = false;
|
button.disabled = false;
|
||||||
button.textContent = t('screens.notifications_view.text_011');
|
button.textContent = reciprocalRelationLabel(kind);
|
||||||
showToast(toUserMessage(error, t('screens.notifications_view.text_016')), { kind: 'error' });
|
showToast(toUserMessage(error, t('screens.notifications_view.text_016')), { kind: 'error' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,10 +32,11 @@
|
|||||||
border-bottom: 1px solid var(--divider-soft);
|
border-bottom: 1px solid var(--divider-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-card__head { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
|
.notification-card__head { display: flex; align-items: start; gap: var(--space-2); min-width: 0; }
|
||||||
|
|
||||||
|
.notification-card__identity { display: grid; flex: 1 1 auto; min-width: 0; gap: 1px; }
|
||||||
|
|
||||||
.notification-card__name {
|
.notification-card__name {
|
||||||
flex: 1 1 auto;
|
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
font-size: var(--text-md);
|
font-size: var(--text-md);
|
||||||
@@ -45,7 +46,17 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-card__time { flex: 0 0 auto; color: var(--text-secondary); font-size: var(--text-xs); }
|
.notification-card__login {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
line-height: var(--leading-xs);
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-card__time { flex: 0 0 auto; padding-top: 2px; color: var(--text-secondary); font-size: var(--text-xs); }
|
||||||
|
|
||||||
/* Непрочитанное: точка-акцент перед временем. */
|
/* Непрочитанное: точка-акцент перед временем. */
|
||||||
.notification-card--new .notification-card__time::before {
|
.notification-card--new .notification-card__time::before {
|
||||||
|
|||||||
@@ -76,6 +76,25 @@ test('HEADER и PostgreSQL требуют неизменяемого регис
|
|||||||
assert.match(migration, /NEW\.login IS DISTINCT FROM OLD\.login/);
|
assert.match(migration, /NEW\.login IS DISTINCT FROM OLD\.login/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('runtime-state блокчейна использует normalized_login, не отображаемое написание', () => {
|
||||||
|
const migration = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v43.sql', import.meta.url), 'utf8');
|
||||||
|
const state = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/java/shine/db/entities/BlockchainStateEntry.java', import.meta.url), 'utf8');
|
||||||
|
assert.match(migration, /FOREIGN KEY \(login\) REFERENCES user_identity_current\(normalized_login\)/);
|
||||||
|
assert.match(migration, /SET login = LOWER\(BTRIM\(login\)\)/);
|
||||||
|
assert.match(migration, /NEW\.login := LOWER\(BTRIM\(NEW\.login\)\)/);
|
||||||
|
assert.match(state, /toLowerCase\(Locale\.ROOT\)/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('адресат уведомления хранится и ищется по normalized_login', () => {
|
||||||
|
const migration = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v44.sql', import.meta.url), 'utf8');
|
||||||
|
const dao = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/java/shine/db/dao/UserNotificationsStateDAO.java', import.meta.url), 'utf8');
|
||||||
|
assert.match(migration, /SET owner_login = LOWER\(BTRIM\(owner_login\)\)/);
|
||||||
|
assert.match(migration, /NEW\.owner_login := LOWER\(BTRIM\(NEW\.owner_login\)\)/);
|
||||||
|
assert.match(dao, /ps\.setString\(i\+\+, normalizedLogin\(e\.getOwnerLogin\(\)\)\)/);
|
||||||
|
assert.match(dao, /ps\.setString\(1, normalizedLogin\(ownerLogin\)\)/);
|
||||||
|
assert.match(dao, /toLowerCase\(Locale\.ROOT\)/);
|
||||||
|
});
|
||||||
|
|
||||||
test('лента, список подписок и дерево обсуждения возвращают оригинальный регистр автора', () => {
|
test('лента, список подписок и дерево обсуждения возвращают оригинальный регистр автора', () => {
|
||||||
const base = new URL('../../SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/', import.meta.url);
|
const base = new URL('../../SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/', import.meta.url);
|
||||||
const read = (file) => readFileSync(new URL(file, base), 'utf8');
|
const read = (file) => readFileSync(new URL(file, base), 'utf8');
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
const page = readFileSync(new URL('../js/pages/notifications-view.js', import.meta.url), 'utf8');
|
||||||
|
const css = readFileSync(new URL('../styles/features/notifications.css', import.meta.url), 'utf8');
|
||||||
|
|
||||||
|
test('уведомление показывает логин автора под отображаемым именем', () => {
|
||||||
|
assert.match(page, /notification-card__login/);
|
||||||
|
assert.match(page, /login\.textContent = item\.sourceLogin/);
|
||||||
|
assert.match(css, /\.notification-card__login/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ответная связь повторяет тип входящей связи', () => {
|
||||||
|
assert.match(page, /CONNECTION_CLOSE_FRIEND[\s\S]*\? 'close_friend'[\s\S]*: 'friend'/);
|
||||||
|
assert.match(page, /kind, enabled: true/);
|
||||||
|
assert.match(page, /text_072/);
|
||||||
|
assert.match(page, /text_073/);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user