SHA256
Channels UI + read/unread + unique views + style polish
This commit is contained in:
@@ -346,6 +346,34 @@ public final class DatabaseInitializer {
|
||||
ON message_stats (to_login);
|
||||
""");
|
||||
|
||||
// 8.0) message_views_state (уникальный просмотр/прочтение сообщения пользователем)
|
||||
st.executeUpdate("""
|
||||
CREATE TABLE IF NOT EXISTS message_views_state (
|
||||
viewer_login TEXT NOT NULL,
|
||||
to_bch_name TEXT NOT NULL,
|
||||
to_block_number INTEGER NOT NULL,
|
||||
to_block_hash BLOB NOT NULL,
|
||||
first_seen_at_ms INTEGER NOT NULL,
|
||||
|
||||
UNIQUE (
|
||||
viewer_login,
|
||||
to_bch_name,
|
||||
to_block_number,
|
||||
to_block_hash
|
||||
)
|
||||
);
|
||||
""");
|
||||
|
||||
st.executeUpdate("""
|
||||
CREATE INDEX IF NOT EXISTS idx_message_views_state_target
|
||||
ON message_views_state (to_bch_name, to_block_number, to_block_hash);
|
||||
""");
|
||||
|
||||
st.executeUpdate("""
|
||||
CREATE INDEX IF NOT EXISTS idx_message_views_state_viewer_channel
|
||||
ON message_views_state (viewer_login, to_bch_name);
|
||||
""");
|
||||
|
||||
// 8.1) reactions_state (идемпотентный LIKE/UNLIKE per actor/target)
|
||||
st.executeUpdate("""
|
||||
CREATE TABLE IF NOT EXISTS reactions_state (
|
||||
|
||||
@@ -79,6 +79,7 @@ public final class SqliteDbController {
|
||||
st.execute("PRAGMA foreign_keys = OFF");
|
||||
|
||||
ensureReactionsStateTable(st);
|
||||
ensureMessageViewsStateTable(st);
|
||||
|
||||
if (!tableExists(c, "connections_state")) {
|
||||
createConnectionsStateTable(st);
|
||||
@@ -89,6 +90,7 @@ public final class SqliteDbController {
|
||||
ensureChannelNamesDescriptionColumn(c, st);
|
||||
ensureConnectionsIndexes(st);
|
||||
ensureReactionsIndexes(st);
|
||||
ensureMessageViewsIndexes(st);
|
||||
ensureChannelNamesIndexes(st);
|
||||
ensureSignedMessageReceiptUniq(c, st);
|
||||
|
||||
@@ -131,6 +133,24 @@ public final class SqliteDbController {
|
||||
""");
|
||||
}
|
||||
|
||||
private static void ensureMessageViewsStateTable(Statement st) throws SQLException {
|
||||
st.executeUpdate("""
|
||||
CREATE TABLE IF NOT EXISTS message_views_state (
|
||||
viewer_login TEXT NOT NULL,
|
||||
to_bch_name TEXT NOT NULL,
|
||||
to_block_number INTEGER NOT NULL,
|
||||
to_block_hash BLOB NOT NULL,
|
||||
first_seen_at_ms INTEGER NOT NULL,
|
||||
UNIQUE (
|
||||
viewer_login,
|
||||
to_bch_name,
|
||||
to_block_number,
|
||||
to_block_hash
|
||||
)
|
||||
);
|
||||
""");
|
||||
}
|
||||
|
||||
private static void createConnectionsStateTable(Statement st) throws SQLException {
|
||||
st.executeUpdate("""
|
||||
CREATE TABLE IF NOT EXISTS connections_state (
|
||||
@@ -176,6 +196,17 @@ public final class SqliteDbController {
|
||||
""");
|
||||
}
|
||||
|
||||
private static void ensureMessageViewsIndexes(Statement st) throws SQLException {
|
||||
st.executeUpdate("""
|
||||
CREATE INDEX IF NOT EXISTS idx_message_views_state_target
|
||||
ON message_views_state (to_bch_name, to_block_number, to_block_hash);
|
||||
""");
|
||||
st.executeUpdate("""
|
||||
CREATE INDEX IF NOT EXISTS idx_message_views_state_viewer_channel
|
||||
ON message_views_state (viewer_login, to_bch_name);
|
||||
""");
|
||||
}
|
||||
|
||||
private static void ensureChannelNamesStateTable(Statement st) throws SQLException {
|
||||
st.executeUpdate("""
|
||||
CREATE TABLE IF NOT EXISTS channel_names_state (
|
||||
|
||||
Reference in New Issue
Block a user