Add Attachment Support
This commit is contained in:
parent
8f5a2fb61e
commit
5e5a7273e4
2
pom.xml
2
pom.xml
@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.informatik-ag-ngl</groupId>
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
<artifactId>envoy-common</artifactId>
|
<artifactId>envoy-common</artifactId>
|
||||||
<version>develop-SNAPSHOT</version>
|
<version>f~attachment-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.informatik-ag-ngl</groupId>
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
import envoy.data.MessageBuilder;
|
import envoy.data.Group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>envoy-server-standalone</strong><br>
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
@ -57,15 +57,7 @@ public class GroupMessage extends Message {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public envoy.data.GroupMessage toCommon() {
|
public envoy.data.GroupMessage toCommon() {
|
||||||
// TODO: Attachment
|
return prepareBuilder().buildGroupMessage((Group) recipient.toCommon(), memberMessageStatus);
|
||||||
envoy.data.GroupMessage groupMessage = new MessageBuilder(sender.getID(), recipient.getID(), id).setDate(creationDate)
|
|
||||||
.setForwarded(forwarded)
|
|
||||||
.setStatus(status)
|
|
||||||
.setText(text)
|
|
||||||
.buildGroupMessage((envoy.data.Group) recipient.toCommon(), memberMessageStatus);
|
|
||||||
groupMessage.setReceivedDate(receivedDate);
|
|
||||||
groupMessage.setReadDate(readDate);
|
|
||||||
return groupMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,8 @@ import java.time.LocalDateTime;
|
|||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import envoy.data.Attachment;
|
||||||
|
import envoy.data.Attachment.AttachmentType;
|
||||||
import envoy.data.Message.MessageStatus;
|
import envoy.data.Message.MessageStatus;
|
||||||
import envoy.data.MessageBuilder;
|
import envoy.data.MessageBuilder;
|
||||||
|
|
||||||
@ -63,6 +65,7 @@ public class Message {
|
|||||||
|
|
||||||
protected String text;
|
protected String text;
|
||||||
protected envoy.data.Message.MessageStatus status;
|
protected envoy.data.Message.MessageStatus status;
|
||||||
|
protected AttachmentType attachmentType;
|
||||||
protected byte[] attachment;
|
protected byte[] attachment;
|
||||||
protected boolean forwarded;
|
protected boolean forwarded;
|
||||||
|
|
||||||
@ -91,7 +94,10 @@ public class Message {
|
|||||||
sender = persistenceManager.getUserByID(message.getSenderID());
|
sender = persistenceManager.getUserByID(message.getSenderID());
|
||||||
recipient = persistenceManager.getContactByID(message.getRecipientID());
|
recipient = persistenceManager.getContactByID(message.getRecipientID());
|
||||||
forwarded = message.isForwarded();
|
forwarded = message.isForwarded();
|
||||||
// TODO: Attachment
|
if (message.hasAttachment()) {
|
||||||
|
attachment = message.getAttachment().getData();
|
||||||
|
attachmentType = message.getAttachment().getType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,15 +108,23 @@ public class Message {
|
|||||||
* @since Envoy Server Standalone v0.1-alpha
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
*/
|
*/
|
||||||
public envoy.data.Message toCommon() {
|
public envoy.data.Message toCommon() {
|
||||||
// TODO: Attachment
|
return prepareBuilder().build();
|
||||||
envoy.data.Message message = new MessageBuilder(sender.getID(), recipient.getID(), id).setText(text)
|
}
|
||||||
.setDate(creationDate)
|
|
||||||
|
/**
|
||||||
|
* @return a message builder containing the state of this message
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
MessageBuilder prepareBuilder() {
|
||||||
|
var builder = new MessageBuilder(sender.getID(), recipient.getID(), id).setText(
|
||||||
|
text)
|
||||||
|
.setCreationDate(creationDate)
|
||||||
|
.setReceivedDate(receivedDate)
|
||||||
|
.setReadDate(readDate)
|
||||||
.setStatus(status)
|
.setStatus(status)
|
||||||
.setForwarded(forwarded)
|
.setForwarded(forwarded);
|
||||||
.build();
|
if (attachment != null) builder.setAttachment(new Attachment(attachment, attachmentType));
|
||||||
message.setReceivedDate(receivedDate);
|
return builder;
|
||||||
message.setReadDate(readDate);
|
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,6 +264,18 @@ public class Message {
|
|||||||
*/
|
*/
|
||||||
public void setAttachment(byte[] attachment) { this.attachment = attachment; }
|
public void setAttachment(byte[] attachment) { this.attachment = attachment; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the attachmentType
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public AttachmentType getAttachmentType() { return attachmentType; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param attachmentType the attachmentType to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setAttachmentType(AttachmentType attachmentType) { this.attachmentType = attachmentType; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether this message is a forwarded message
|
* @return whether this message is a forwarded message
|
||||||
* @since Envoy Server Standalone v0.1-alpha
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
Reference in New Issue
Block a user