Message and Message Database updated based on new init.sql.
This commit is contained in:
@@ -172,7 +172,8 @@ public class MessageDatabase {
|
|||||||
rs.getBoolean("is_edited"),
|
rs.getBoolean("is_edited"),
|
||||||
rs.getObject("original_message_id") != null ? UUID.fromString(rs.getString("original_message_id")) : null,
|
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_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.getBoolean("is_deleted_globally")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +274,8 @@ public class MessageDatabase {
|
|||||||
rs.getBoolean("is_edited"),
|
rs.getBoolean("is_edited"),
|
||||||
(UUID) rs.getObject("original_message_id"),
|
(UUID) rs.getObject("original_message_id"),
|
||||||
(UUID) rs.getObject("forwarded_by"),
|
(UUID) rs.getObject("forwarded_by"),
|
||||||
(UUID) rs.getObject("forwarded_from")
|
(UUID) rs.getObject("forwarded_from"),
|
||||||
|
rs.getBoolean("is_deleted_globally")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,5 +482,21 @@ public class MessageDatabase {
|
|||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean insertSavedMessage(Message message) {
|
||||||
|
String sql = "INSERT INTO messages (message_id, sender_id, receiver_type, receiver_id, content, message_type, status) " +
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
try (Connection conn = ConnectionDb.connect();
|
||||||
|
PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||||
|
|
||||||
|
|
||||||
|
return ps.executeUpdate() > 0;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ public class Message {
|
|||||||
private UUID forwarded_by;
|
private UUID forwarded_by;
|
||||||
private UUID forwarded_from;
|
private UUID forwarded_from;
|
||||||
private List<FileAttachment> attachments;
|
private List<FileAttachment> attachments;
|
||||||
|
private boolean is_deleted_globally;
|
||||||
|
|
||||||
public Message(UUID message_id, UUID sender_id, String receiver_type, UUID receiver_id, String content,
|
public Message(UUID message_id, UUID sender_id, String receiver_type, UUID receiver_id, String content,
|
||||||
String message_type, LocalDateTime send_at, String status,
|
String message_type, LocalDateTime send_at, String status,
|
||||||
UUID reply_to_id, boolean is_edited, UUID original_message_id,
|
UUID reply_to_id, boolean is_edited, UUID original_message_id,
|
||||||
UUID forwarded_by, UUID forwarded_from) {
|
UUID forwarded_by, UUID forwarded_from,boolean is_deleted_globally) {
|
||||||
this.message_id = message_id;
|
this.message_id = message_id;
|
||||||
this.sender_id = sender_id;
|
this.sender_id = sender_id;
|
||||||
this.receiver_type = receiver_type;
|
this.receiver_type = receiver_type;
|
||||||
@@ -37,6 +38,7 @@ public class Message {
|
|||||||
this.original_message_id = original_message_id;
|
this.original_message_id = original_message_id;
|
||||||
this.forwarded_by = forwarded_by;
|
this.forwarded_by = forwarded_by;
|
||||||
this.forwarded_from = forwarded_from;
|
this.forwarded_from = forwarded_from;
|
||||||
|
this.is_deleted_globally = is_deleted_globally;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message(UUID messageId, UUID senderId, UUID receiverId, String receiverType, String content, String messageType, LocalDateTime now) {
|
public Message(UUID messageId, UUID senderId, UUID receiverId, String receiverType, String content, String messageType, LocalDateTime now) {
|
||||||
@@ -157,4 +159,11 @@ public class Message {
|
|||||||
public List<FileAttachment> getAttachments() {
|
public List<FileAttachment> getAttachments() {
|
||||||
return attachments;
|
return attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIs_deleted_globally(boolean is_deleted_globally) {
|
||||||
|
this.is_deleted_globally = is_deleted_globally;
|
||||||
|
}
|
||||||
|
public boolean getIs_deleted_globally() {
|
||||||
|
return is_deleted_globally;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user