Merge branch 'develop' into Sidebar-Menu
# Conflicts: # src/main/java/org/to/telegramfinalproject/Client/ActionHandler.java # src/main/java/org/to/telegramfinalproject/Database/PrivateChatDatabase.java # src/main/java/org/to/telegramfinalproject/Server/ClientHandler.java
This commit is contained in:
@@ -12,8 +12,10 @@ public class ChatEntry {
|
||||
private String imageUrl;
|
||||
private String type;
|
||||
private LocalDateTime lastMessageTime;
|
||||
private boolean archived = false;
|
||||
private UUID otherUser;
|
||||
|
||||
|
||||
// 🔹 نقشها
|
||||
private boolean isOwner = false;
|
||||
private boolean isAdmin = false;
|
||||
private JSONObject permissions;
|
||||
@@ -28,7 +30,6 @@ public class ChatEntry {
|
||||
this.lastMessageTime = lastMessageTime;
|
||||
}
|
||||
|
||||
// ✅ کانستراکتور اضافهشده برای پشتیبانی از نقشها (اختیاری، برای استفادههای جدید)
|
||||
public ChatEntry(UUID internalId, String displayId, String name, String imageUrl, String type, LocalDateTime lastMessageTime, boolean isOwner, boolean isAdmin) {
|
||||
this(internalId, displayId, name, imageUrl, type, lastMessageTime);
|
||||
this.isOwner = isOwner;
|
||||
@@ -41,7 +42,6 @@ public class ChatEntry {
|
||||
|
||||
}
|
||||
|
||||
// 🟩 گتر و ستر جدید
|
||||
public boolean isOwner() {
|
||||
return isOwner;
|
||||
}
|
||||
@@ -108,4 +108,36 @@ public class ChatEntry {
|
||||
|
||||
|
||||
|
||||
public boolean isArchived() {
|
||||
return archived;
|
||||
}
|
||||
|
||||
public void setArchived(boolean archived) {
|
||||
this.archived = archived;
|
||||
}
|
||||
|
||||
// public void setLastMessageTime(String newTime) {this.lastMessageTime = LocalDateTime.parse(newTime);
|
||||
// }
|
||||
|
||||
|
||||
public void setLastMessageTime(String newTime) {
|
||||
if (newTime == null || newTime.isBlank()) {
|
||||
this.lastMessageTime = null;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.lastMessageTime = LocalDateTime.parse(newTime);
|
||||
} catch (Exception e) {
|
||||
System.out.println("❌ Failed to parse lastMessageTime: " + newTime);
|
||||
this.lastMessageTime = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setOtherUserId(UUID otherId) {this.otherUser = otherId;
|
||||
}
|
||||
|
||||
public UUID getOtherUserId(){
|
||||
return otherUser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ContactEntry {
|
||||
private UUID contactId; // internal UUID
|
||||
private String userId; // public ID
|
||||
private String profileName;
|
||||
private String imageUrl;
|
||||
private boolean isBlocked;
|
||||
|
||||
public ContactEntry(UUID contactId, String userId, String profileName, String imageUrl, boolean isBlocked) {
|
||||
this.contactId = contactId;
|
||||
this.userId = userId;
|
||||
this.profileName = profileName;
|
||||
this.imageUrl = imageUrl;
|
||||
this.isBlocked = isBlocked;
|
||||
}
|
||||
|
||||
public UUID getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getProfileName() {
|
||||
return profileName;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return isBlocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return profileName + " (" + userId + ")" + (isBlocked ? " [Blocked]" : "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
public class FileAttachment {
|
||||
private String fileUrl;
|
||||
private String fileType;
|
||||
|
||||
public FileAttachment(String fileUrl, String fileType) {
|
||||
this.fileUrl = fileUrl;
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
public String getFileUrl() {
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
public String getFileType() {
|
||||
return fileType;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,6 @@ public class JsonUtil {
|
||||
obj.put("receiver_id", message.getReceiver_id().toString());
|
||||
obj.put("content", message.getContent());
|
||||
obj.put("message_type", message.getMessage_type());
|
||||
obj.put("file_url", message.getFile_url());
|
||||
obj.put("send_at", message.getSend_at().toString());
|
||||
obj.put("status", message.getStatus());
|
||||
obj.put("reply_to_id", message.getReply_to_id() != null ? message.getReply_to_id().toString() : JSONObject.NULL);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Message {
|
||||
@@ -10,7 +11,6 @@ public class Message {
|
||||
private UUID receiver_id;
|
||||
private String content;
|
||||
private String message_type; // TEXT, IMAGE, FILE, ...
|
||||
private String file_url;
|
||||
private LocalDateTime send_at;
|
||||
private String status; // SENT, DELIVERED, READ
|
||||
private UUID reply_to_id;
|
||||
@@ -18,9 +18,10 @@ public class Message {
|
||||
private UUID original_message_id;
|
||||
private UUID forwarded_by;
|
||||
private UUID forwarded_from;
|
||||
private List<FileAttachment> attachments;
|
||||
|
||||
public Message(UUID message_id, UUID sender_id, String receiver_type, UUID receiver_id, String content,
|
||||
String message_type, String file_url, 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 forwarded_by, UUID forwarded_from) {
|
||||
this.message_id = message_id;
|
||||
@@ -29,7 +30,6 @@ public class Message {
|
||||
this.receiver_id = receiver_id;
|
||||
this.content = content;
|
||||
this.message_type = message_type;
|
||||
this.file_url = file_url;
|
||||
this.send_at = send_at;
|
||||
this.status = status;
|
||||
this.reply_to_id = reply_to_id;
|
||||
@@ -39,6 +39,16 @@ public class Message {
|
||||
this.forwarded_from = forwarded_from;
|
||||
}
|
||||
|
||||
public Message(UUID messageId, UUID senderId, UUID receiverId, String receiverType, String content, String messageType, LocalDateTime now) {
|
||||
this.message_id = messageId;
|
||||
this.sender_id = senderId;
|
||||
this.receiver_id = receiverId;
|
||||
this.receiver_type = receiverType;
|
||||
this.content = content;
|
||||
this.message_type = messageType;
|
||||
this.send_at = now;
|
||||
}
|
||||
|
||||
|
||||
public UUID getMessage_id() {
|
||||
return message_id;
|
||||
@@ -85,14 +95,6 @@ public class Message {
|
||||
this.message_type = message_type;
|
||||
}
|
||||
|
||||
public String getFile_url() {
|
||||
return file_url;
|
||||
}
|
||||
|
||||
public void setFile_url(String file_url) {
|
||||
this.file_url = file_url;
|
||||
}
|
||||
|
||||
public LocalDateTime getSend_at() {
|
||||
return send_at;
|
||||
}
|
||||
@@ -148,4 +150,11 @@ public class Message {
|
||||
public void setForwarded_from(UUID forwarded_from) {
|
||||
this.forwarded_from = forwarded_from;
|
||||
}
|
||||
|
||||
public void setAttachments(List<FileAttachment> attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
public List<FileAttachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,29 @@ import java.util.UUID;
|
||||
|
||||
public class PrivateChat {
|
||||
private final UUID chat_id;
|
||||
private boolean user1_deleted;
|
||||
private boolean user2_deleted;
|
||||
private UUID user1_id;
|
||||
private UUID user2_id;
|
||||
private LocalDateTime created_at;
|
||||
|
||||
public PrivateChat(UUID chat_id, UUID user1_id, UUID user2_id, LocalDateTime created_at){
|
||||
public PrivateChat(UUID chat_id, UUID user1_id, UUID user2_id){
|
||||
this.chat_id = chat_id;
|
||||
this.user1_id =user1_id;
|
||||
this.user2_id =user2_id;
|
||||
this.created_at =created_at;
|
||||
}
|
||||
|
||||
public PrivateChat(UUID chatId, UUID user1, UUID user2, boolean user1Deleted, boolean user2Deleted, LocalDateTime createdAt) {
|
||||
this.chat_id = chatId;
|
||||
this.user1_id = user1;
|
||||
this.user2_id = user2;
|
||||
this.user1_deleted = user1Deleted;
|
||||
this.user2_deleted = user2Deleted;
|
||||
this.created_at = createdAt;
|
||||
}
|
||||
|
||||
|
||||
public void setUser1_id(UUID user1_id){this.user1_id =user1_id;}
|
||||
public void setUser2_id(UUID user2_id){this.user2_id =user2_id;}
|
||||
public void setCreated_at(LocalDateTime created_at){this.created_at = created_at;}
|
||||
|
||||
Reference in New Issue
Block a user