mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Store urgent field in database
This commit is contained in:
parent
2c586266ff
commit
38c9fe9cb5
2 changed files with 15 additions and 6 deletions
|
@ -22,7 +22,7 @@ import java.sql.SQLException;
|
||||||
public class AccountDatabase extends Database {
|
public class AccountDatabase extends Database {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(AccountDatabase.class);
|
private final static Logger logger = LoggerFactory.getLogger(AccountDatabase.class);
|
||||||
private static final long DATABASE_VERSION = 8;
|
private static final long DATABASE_VERSION = 9;
|
||||||
|
|
||||||
private AccountDatabase(final HikariDataSource dataSource) {
|
private AccountDatabase(final HikariDataSource dataSource) {
|
||||||
super(logger, DATABASE_VERSION, dataSource);
|
super(logger, DATABASE_VERSION, dataSource);
|
||||||
|
@ -204,5 +204,13 @@ public class AccountDatabase extends Database {
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 9) {
|
||||||
|
logger.debug("Updating database: Adding urgent field");
|
||||||
|
try (final var statement = connection.createStatement()) {
|
||||||
|
statement.executeUpdate("""
|
||||||
|
ALTER TABLE message_send_log_content ADD COLUMN urgent BOOLEAN NOT NULL DEFAULT TRUE;
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
group_id BLOB,
|
group_id BLOB,
|
||||||
timestamp INTEGER NOT NULL,
|
timestamp INTEGER NOT NULL,
|
||||||
content BLOB NOT NULL,
|
content BLOB NOT NULL,
|
||||||
content_hint INTEGER NOT NULL
|
content_hint INTEGER NOT NULL,
|
||||||
|
urgent BOOLEAN NOT NULL
|
||||||
);
|
);
|
||||||
CREATE INDEX mslc_timestamp_index ON message_send_log_content (timestamp);
|
CREATE INDEX mslc_timestamp_index ON message_send_log_content (timestamp);
|
||||||
CREATE INDEX msl_recipient_index ON message_send_log (recipient_id, device_id, content_id);
|
CREATE INDEX msl_recipient_index ON message_send_log (recipient_id, device_id, content_id);
|
||||||
|
@ -112,7 +113,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final var contentHint = ContentHint.fromType(resultSet.getInt("content_hint"));
|
final var contentHint = ContentHint.fromType(resultSet.getInt("content_hint"));
|
||||||
final var urgent = true; // TODO
|
final var urgent = resultSet.getBoolean("urgent");
|
||||||
return new MessageSendLogEntry(groupId, content, contentHint, urgent);
|
return new MessageSendLogEntry(groupId, content, contentHint, urgent);
|
||||||
})) {
|
})) {
|
||||||
return result.filter(Objects::nonNull)
|
return result.filter(Objects::nonNull)
|
||||||
|
@ -274,10 +275,9 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
) {
|
) {
|
||||||
byte[] groupId = getGroupId(content);
|
byte[] groupId = getGroupId(content);
|
||||||
|
|
||||||
// TODO store urgent
|
|
||||||
final var sql = """
|
final var sql = """
|
||||||
INSERT INTO %s (timestamp, group_id, content, content_hint)
|
INSERT INTO %s (timestamp, group_id, content, content_hint, urgent)
|
||||||
VALUES (?,?,?,?)
|
VALUES (?,?,?,?,?)
|
||||||
""".formatted(TABLE_MESSAGE_SEND_LOG_CONTENT);
|
""".formatted(TABLE_MESSAGE_SEND_LOG_CONTENT);
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
|
@ -287,6 +287,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
statement.setBytes(2, groupId);
|
statement.setBytes(2, groupId);
|
||||||
statement.setBytes(3, content.toByteArray());
|
statement.setBytes(3, content.toByteArray());
|
||||||
statement.setInt(4, contentHint.getType());
|
statement.setInt(4, contentHint.getType());
|
||||||
|
statement.setBoolean(5, urgent);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
final var generatedKeys = statement.getGeneratedKeys();
|
final var generatedKeys = statement.getGeneratedKeys();
|
||||||
if (generatedKeys.next()) {
|
if (generatedKeys.next()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue