mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update dependencies
This commit is contained in:
parent
4d93415485
commit
e626cc0390
7 changed files with 198 additions and 178 deletions
|
@ -113,6 +113,10 @@ public class Utils {
|
|||
}, false);
|
||||
}
|
||||
|
||||
public static Long getIdMapper(ResultSet resultSet) throws SQLException {
|
||||
return resultSet.getLong("_id");
|
||||
}
|
||||
|
||||
public interface ResultSetMapper<T> {
|
||||
|
||||
T apply(ResultSet resultSet) throws SQLException;
|
||||
|
|
|
@ -241,6 +241,7 @@ public class GroupStore {
|
|||
final var sql = """
|
||||
INSERT OR REPLACE INTO %s (_id, group_id, group_id_v2, name, color, expiration_time, blocked, archived)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING _id
|
||||
""".formatted(TABLE_GROUP_V1);
|
||||
try (final var statement = connection.prepareStatement(sql)) {
|
||||
if (internalId == null) {
|
||||
|
@ -255,14 +256,13 @@ public class GroupStore {
|
|||
statement.setLong(6, groupV1.getMessageExpirationTimer());
|
||||
statement.setBoolean(7, groupV1.isBlocked());
|
||||
statement.setBoolean(8, groupV1.archived);
|
||||
statement.executeUpdate();
|
||||
final var generatedKey = Utils.executeQueryForOptional(statement, Utils::getIdMapper);
|
||||
|
||||
if (internalId == null) {
|
||||
final var generatedKeys = statement.getGeneratedKeys();
|
||||
if (generatedKeys.next()) {
|
||||
internalId = generatedKeys.getLong(1);
|
||||
if (generatedKey.isPresent()) {
|
||||
internalId = generatedKey.get();
|
||||
} else {
|
||||
throw new RuntimeException("Failed to add new recipient to database");
|
||||
throw new RuntimeException("Failed to add new group to database");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -750,6 +750,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
"""
|
||||
INSERT INTO %s (number, uuid, pni)
|
||||
VALUES (?, ?, ?)
|
||||
RETURNING _id
|
||||
"""
|
||||
).formatted(TABLE_RECIPIENT);
|
||||
try (final var statement = connection.prepareStatement(sql)) {
|
||||
|
@ -757,10 +758,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
statement.setBytes(2,
|
||||
address.serviceId().map(ServiceId::getRawUuid).map(UuidUtil::toByteArray).orElse(null));
|
||||
statement.setBytes(3, address.pni().map(PNI::getRawUuid).map(UuidUtil::toByteArray).orElse(null));
|
||||
statement.executeUpdate();
|
||||
final var generatedKeys = statement.getGeneratedKeys();
|
||||
if (generatedKeys.next()) {
|
||||
final var recipientId = new RecipientId(generatedKeys.getLong(1), this);
|
||||
final var generatedKey = Utils.executeQueryForOptional(statement, Utils::getIdMapper);
|
||||
if (generatedKey.isPresent()) {
|
||||
final var recipientId = new RecipientId(generatedKey.get(), this);
|
||||
logger.debug("Added new recipient {} with address {}", recipientId, address);
|
||||
return recipientId;
|
||||
} else {
|
||||
|
|
|
@ -276,6 +276,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
final var sql = """
|
||||
INSERT INTO %s (timestamp, group_id, content, content_hint, urgent)
|
||||
VALUES (?,?,?,?,?)
|
||||
RETURNING _id
|
||||
""".formatted(TABLE_MESSAGE_SEND_LOG_CONTENT);
|
||||
try (final var connection = database.getConnection()) {
|
||||
connection.setAutoCommit(false);
|
||||
|
@ -286,10 +287,9 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
statement.setBytes(3, content.toByteArray());
|
||||
statement.setInt(4, contentHint.getType());
|
||||
statement.setBoolean(5, urgent);
|
||||
statement.executeUpdate();
|
||||
final var generatedKeys = statement.getGeneratedKeys();
|
||||
if (generatedKeys.next()) {
|
||||
contentId = generatedKeys.getLong(1);
|
||||
final var generatedKey = Utils.executeQueryForOptional(statement, Utils::getIdMapper);
|
||||
if (generatedKey.isPresent()) {
|
||||
contentId = generatedKey.get();
|
||||
} else {
|
||||
contentId = -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue