From a418d3efbcd26240f49ab73a6e30cd0901623bc1 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Tue, 31 Dec 2019 16:38:07 +0200 Subject: [PATCH] Storing sender and recipient IDs in message, added contact list to User --- src/main/java/envoy/data/Message.java | 19 +++++++++++++++++-- src/main/java/envoy/data/User.java | 13 +++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/java/envoy/data/Message.java b/src/main/java/envoy/data/Message.java index b2f6545..ddbfba2 100644 --- a/src/main/java/envoy/data/Message.java +++ b/src/main/java/envoy/data/Message.java @@ -48,8 +48,8 @@ public class Message implements Serializable { READ } - private final long id; - private final User sender, recipient; + private final long id, senderId, recipientId; + private final transient User sender, recipient; private final Date date; private final String text; private final MessageAttachment attachment; @@ -81,6 +81,9 @@ public class Message implements Serializable { this.text = text; this.attachment = attachment; this.status = status; + + senderId = sender.getId(); + recipientId = recipient.getId(); } /** @@ -124,12 +127,24 @@ public class Message implements Serializable { */ public User getSender() { return sender; } + /** + * @return the sender ID of this message + * @since Envoy Common v0.2-alpha + */ + public long getSenderId() { return senderId; } + /** * @return the recipient of this message * @since Envoy Common v0.2-alpha */ public User getRecipient() { return recipient; } + /** + * @return the recipient ID of this message + * @since Envoy Common v0.2-alpha + */ + public long getRecipientId() { return recipientId; } + /** * @return the date at which this message was created * @since Envoy Common v0.2-alpha diff --git a/src/main/java/envoy/data/User.java b/src/main/java/envoy/data/User.java index de29fc4..d5c0bbc 100644 --- a/src/main/java/envoy/data/User.java +++ b/src/main/java/envoy/data/User.java @@ -1,6 +1,8 @@ package envoy.data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * Represents a unique user with a unique, numeric ID, a name and a current @@ -44,8 +46,9 @@ public class User implements Serializable { OFFLINE; } - private final long id; - private final String name; + private final long id; + private final String name; + private final List contacts = new ArrayList<>(); private UserStatus status; @@ -80,6 +83,12 @@ public class User implements Serializable { */ public String getName() { return name; } + /** + * @return a list of all users this user can send messages to + * @since Envoy Client v0.2-alpha + */ + public List getContacts() { return contacts; } + /** * @return the current status of this user * @since Envoy Client v0.2-alpha