Edit text messages

This commit is contained in:
2025-08-07 13:57:29 +03:30
parent ad37f3f26c
commit 33a6c5e55d
4 changed files with 116 additions and 6 deletions
@@ -153,7 +153,12 @@ public class MessageDatabase {
rs.getBoolean("is_deleted_globally"),
rs.getObject("original_message_id") != null ? UUID.fromString(rs.getString("original_message_id")) : null,
rs.getObject("forwarded_by") != null ? UUID.fromString(rs.getString("forwarded_by")) : null,
rs.getObject("forwarded_from") != null ? UUID.fromString(rs.getString("forwarded_from")) : null
rs.getObject("forwarded_from") != null ? UUID.fromString(rs.getString("forwarded_from")) : null,
rs.getTimestamp("edited_at") != null
? rs.getTimestamp("edited_at").toLocalDateTime()
: null
);
messages.add(msg);
@@ -222,6 +227,26 @@ public class MessageDatabase {
}
}
public static boolean updateContentAndMarkEdited(UUID messageId, String newContent) {
String sql = """
UPDATE messages
SET content = ?, is_edited = TRUE, edited_at = CURRENT_TIMESTAMP
WHERE message_id = ?
""";
try (Connection conn = ConnectionDb.connect();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setString(1, newContent);
ps.setObject(2, messageId);
return ps.executeUpdate() > 0;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
public void markMessageAsRead(UUID messageId, UUID userId) {
String sql = "INSERT INTO message_receipts (message_id, user_id) VALUES (?, ?) ON CONFLICT DO NOTHING";