Added option to disable attachments and groups on both client and server
This commit is contained in:
parent
eb4e421974
commit
c784ebb787
@ -164,6 +164,13 @@ public final class Client implements Closeable {
|
|||||||
// Process ProfilePicChanges
|
// Process ProfilePicChanges
|
||||||
receiver.registerProcessor(ProfilePicChange.class, eventBus::dispatch);
|
receiver.registerProcessor(ProfilePicChange.class, eventBus::dispatch);
|
||||||
|
|
||||||
|
// Process requests to not send anymore attachments as they will not be shown to
|
||||||
|
// other users
|
||||||
|
receiver.registerProcessor(NoAttachments.class, eventBus::dispatch);
|
||||||
|
|
||||||
|
// Process group creation rejections - they have been disabled on the server
|
||||||
|
receiver.registerProcessor(GroupCreationResult.class, eventBus::dispatch);
|
||||||
|
|
||||||
// Send event
|
// Send event
|
||||||
eventBus.register(SendEvent.class, evt -> {
|
eventBus.register(SendEvent.class, evt -> {
|
||||||
try {
|
try {
|
||||||
|
@ -69,7 +69,7 @@ public final class Receiver extends Thread {
|
|||||||
// Server has stopped sending, i.e. because he went offline
|
// Server has stopped sending, i.e. because he went offline
|
||||||
if (len == 0 && bytesRead == -1) {
|
if (len == 0 && bytesRead == -1) {
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
logger.log(Level.WARNING, "Lost connection to the server. Exiting receiver");
|
logger.log(Level.INFO, "Lost connection to the server. Exiting receiver...");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logger.log(Level.WARNING,
|
logger.log(Level.WARNING,
|
||||||
|
@ -87,6 +87,12 @@ public final class ChatScene implements Restorable {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button rotateButton;
|
private Button rotateButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button messageSearchButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button newGroupButton;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TextArea messageTextArea;
|
private TextArea messageTextArea;
|
||||||
|
|
||||||
@ -108,9 +114,6 @@ public final class ChatScene implements Restorable {
|
|||||||
@FXML
|
@FXML
|
||||||
private Label topBarStatusLabel;
|
private Label topBarStatusLabel;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button messageSearchButton;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ImageView clientProfilePic;
|
private ImageView clientProfilePic;
|
||||||
|
|
||||||
@ -129,6 +132,7 @@ public final class ChatScene implements Restorable {
|
|||||||
private AudioRecorder recorder;
|
private AudioRecorder recorder;
|
||||||
private boolean recording;
|
private boolean recording;
|
||||||
private Attachment pendingAttachment;
|
private Attachment pendingAttachment;
|
||||||
|
|
||||||
private boolean postingPermanentlyDisabled;
|
private boolean postingPermanentlyDisabled;
|
||||||
|
|
||||||
private final SystemCommandsMap messageTextAreaCommands = new SystemCommandsMap();
|
private final SystemCommandsMap messageTextAreaCommands = new SystemCommandsMap();
|
||||||
@ -237,6 +241,21 @@ public final class ChatScene implements Restorable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Disable attachment button if server says attachments will be filtered out
|
||||||
|
eventBus.register(NoAttachments.class, e -> {
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
attachmentButton.setDisable(true);
|
||||||
|
voiceButton.setDisable(true);
|
||||||
|
final var alert = new Alert(AlertType.ERROR);
|
||||||
|
alert.setTitle("No attachments possible");
|
||||||
|
alert.setHeaderText("Your current server does not support attachments.");
|
||||||
|
alert.setContentText("If this is unplanned, please contact your server administrator.");
|
||||||
|
alert.showAndWait();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> { newGroupButton.setDisable(!e.get()); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,10 +6,8 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.Alert.AlertType;
|
import javafx.scene.control.Alert.AlertType;
|
||||||
import javafx.scene.control.ButtonType;
|
|
||||||
import javafx.scene.control.ListView;
|
|
||||||
|
|
||||||
import envoy.client.data.LocalDB;
|
import envoy.client.data.LocalDB;
|
||||||
import envoy.client.event.SendEvent;
|
import envoy.client.event.SendEvent;
|
||||||
@ -20,6 +18,7 @@ import envoy.client.ui.listcell.ListCellFactory;
|
|||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
import envoy.event.ElementOperation;
|
import envoy.event.ElementOperation;
|
||||||
import envoy.event.EventBus;
|
import envoy.event.EventBus;
|
||||||
|
import envoy.event.GroupCreationResult;
|
||||||
import envoy.event.contact.ContactOperation;
|
import envoy.event.contact.ContactOperation;
|
||||||
import envoy.event.contact.UserSearchRequest;
|
import envoy.event.contact.UserSearchRequest;
|
||||||
import envoy.event.contact.UserSearchResult;
|
import envoy.event.contact.UserSearchResult;
|
||||||
@ -50,6 +49,9 @@ public final class ContactSearchScene {
|
|||||||
@FXML
|
@FXML
|
||||||
private ListView<User> userList;
|
private ListView<User> userList;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button newGroupButton;
|
||||||
|
|
||||||
private SceneContext sceneContext;
|
private SceneContext sceneContext;
|
||||||
|
|
||||||
private LocalDB localDB;
|
private LocalDB localDB;
|
||||||
@ -86,6 +88,7 @@ public final class ContactSearchScene {
|
|||||||
eventBus.register(UserSearchResult.class,
|
eventBus.register(UserSearchResult.class,
|
||||||
response -> Platform.runLater(() -> { userList.getItems().clear(); userList.getItems().addAll(response.get()); }));
|
response -> Platform.runLater(() -> { userList.getItems().clear(); userList.getItems().addAll(response.get()); }));
|
||||||
eventBus.register(ContactOperation.class, handler);
|
eventBus.register(ContactOperation.class, handler);
|
||||||
|
eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> { newGroupButton.setDisable(!e.get()); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import envoy.data.Group;
|
|||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
import envoy.event.EventBus;
|
import envoy.event.EventBus;
|
||||||
import envoy.event.GroupCreation;
|
import envoy.event.GroupCreation;
|
||||||
|
import envoy.event.GroupCreationResult;
|
||||||
import envoy.util.Bounds;
|
import envoy.util.Bounds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +55,8 @@ public final class GroupCreationScene {
|
|||||||
|
|
||||||
private LocalDB localDB;
|
private LocalDB localDB;
|
||||||
|
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
private static final EventBus eventBus = EventBus.getInstance();
|
private static final EventBus eventBus = EventBus.getInstance();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -61,6 +64,18 @@ public final class GroupCreationScene {
|
|||||||
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
||||||
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
groupNameField.setClearButtonListener(e -> { groupNameField.getTextField().clear(); createButton.setDisable(true); });
|
groupNameField.setClearButtonListener(e -> { groupNameField.getTextField().clear(); createButton.setDisable(true); });
|
||||||
|
eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> {
|
||||||
|
if (e.get()) new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", groupName)).showAndWait();
|
||||||
|
else {
|
||||||
|
createButton.setDisable(true);
|
||||||
|
final var alert = new Alert(AlertType.ERROR);
|
||||||
|
alert.setTitle("Groups are not allowed");
|
||||||
|
alert.setHeaderText("Cannot create group as your current server disabled this feature");
|
||||||
|
alert.setContentText("If this is unplanned, please contact your server administrator.");
|
||||||
|
alert.showAndWait();
|
||||||
|
sceneContext.pop();
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,10 +134,7 @@ public final class GroupCreationScene {
|
|||||||
alert.setTitle("Create Group?");
|
alert.setTitle("Create Group?");
|
||||||
alert.setHeaderText("Proceed?");
|
alert.setHeaderText("Proceed?");
|
||||||
alert.showAndWait().filter(btn -> btn == ButtonType.OK).ifPresent(btn -> createGroup(name));
|
alert.showAndWait().filter(btn -> btn == ButtonType.OK).ifPresent(btn -> createGroup(name));
|
||||||
} else {
|
} else createGroup(name);
|
||||||
new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", name)).showAndWait();
|
|
||||||
createGroup(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,9 +145,9 @@ public final class GroupCreationScene {
|
|||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
private void createGroup(String name) {
|
private void createGroup(String name) {
|
||||||
|
groupName = name;
|
||||||
eventBus.dispatch(new SendEvent(
|
eventBus.dispatch(new SendEvent(
|
||||||
new GroupCreation(name, userList.getSelectionModel().getSelectedItems().stream().map(User::getID).collect(Collectors.toSet()))));
|
new GroupCreation(name, userList.getSelectionModel().getSelectedItems().stream().map(User::getID).collect(Collectors.toSet()))));
|
||||||
sceneContext.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
<Insets />
|
<Insets />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Button mnemonicParsing="false" prefWidth="100.0" text="New Group">
|
<Button fx:id="newGroupButton" mnemonicParsing="false" prefWidth="100.0" text="New Group">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets />
|
<Insets />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
wrapText="true" />
|
wrapText="true" />
|
||||||
</tooltip>
|
</tooltip>
|
||||||
</ClearableTextField>
|
</ClearableTextField>
|
||||||
<Button mnemonicParsing="false"
|
<Button fx:id="newGroupButton" mnemonicParsing="false"
|
||||||
onAction="#newGroupButtonClicked" prefHeight="26.0"
|
onAction="#newGroupButtonClicked" prefHeight="26.0"
|
||||||
prefWidth="139.0" text="New Group">
|
prefWidth="139.0" text="New Group">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
|
25
common/src/main/java/envoy/event/GroupCreationResult.java
Normal file
25
common/src/main/java/envoy/event/GroupCreationResult.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package envoy.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to communicate with a client that his request to create a group might
|
||||||
|
* have been rejected as it might be disabled on his current server.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>common</strong><br>
|
||||||
|
* File: <strong>GroupCreationResult.java</strong><br>
|
||||||
|
* Created: <strong>22.08.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @since Envoy Common v0.2-beta
|
||||||
|
*/
|
||||||
|
public class GroupCreationResult extends Event<Boolean> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@code GroupCreationResult}.
|
||||||
|
*
|
||||||
|
* @param success whether the GroupCreation sent before was successful
|
||||||
|
* @since Envoy Common v0.2-beta
|
||||||
|
*/
|
||||||
|
public GroupCreationResult(boolean success) { super(success); }
|
||||||
|
}
|
25
common/src/main/java/envoy/event/NoAttachments.java
Normal file
25
common/src/main/java/envoy/event/NoAttachments.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package envoy.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This event is used so that the server can tell the client that attachments
|
||||||
|
* will be filtered out.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>common</strong><br>
|
||||||
|
* File: <strong>NoAttachments.java</strong><br>
|
||||||
|
* Created: <strong>22.08.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @since Envoy Common v0.2-beta
|
||||||
|
*/
|
||||||
|
public class NoAttachments extends Event<Void> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@code NoAttachments}.
|
||||||
|
*
|
||||||
|
* @since Envoy Common v0.2-beta
|
||||||
|
*/
|
||||||
|
public NoAttachments() { super(null); }
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package envoy.server.data;
|
package envoy.server.data;
|
||||||
|
|
||||||
import static envoy.data.Message.MessageStatus.*;
|
import static envoy.data.Message.MessageStatus.*;
|
||||||
|
import static envoy.server.Startup.config;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ 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();
|
||||||
if (message.hasAttachment()) {
|
if (config.isAttachmentSupportEnabled() && message.hasAttachment()) {
|
||||||
final var messageAttachment = message.getAttachment();
|
final var messageAttachment = message.getAttachment();
|
||||||
attachment = messageAttachment.getData();
|
attachment = messageAttachment.getData();
|
||||||
attachmentName = messageAttachment.getName();
|
attachmentName = messageAttachment.getName();
|
||||||
|
@ -33,6 +33,8 @@ public final class ServerConfig extends Config {
|
|||||||
put("featureLabel", "l-f", identity(), true);
|
put("featureLabel", "l-f", identity(), true);
|
||||||
// enabling/ disabling several processors
|
// enabling/ disabling several processors
|
||||||
put("enableIssueReporting", "e-ir", Boolean::parseBoolean, true);
|
put("enableIssueReporting", "e-ir", Boolean::parseBoolean, true);
|
||||||
|
put("enableGroups", "e-g", Boolean::parseBoolean, true);
|
||||||
|
put("enableAttachments", "e-a", Boolean::parseBoolean, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,6 +49,18 @@ public final class ServerConfig extends Config {
|
|||||||
*/
|
*/
|
||||||
public Boolean isIssueReportingEnabled() { return (Boolean) items.get("enableIssueReporting").get(); }
|
public Boolean isIssueReportingEnabled() { return (Boolean) items.get("enableIssueReporting").get(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if attachment support has been enabled
|
||||||
|
* @since Envoy Client v0.3-alpha
|
||||||
|
*/
|
||||||
|
public Boolean isAttachmentSupportEnabled() { return (Boolean) items.get("enableAttachments").get(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if group support has been enabled
|
||||||
|
* @since Envoy Client v0.3-alpha
|
||||||
|
*/
|
||||||
|
public Boolean isGroupSupportEnabled() { return (Boolean) items.get("enableGroups").get(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the URL where issues should be uploaded to
|
* @return the URL where issues should be uploaded to
|
||||||
* @since Envoy Client v0.1-alpha
|
* @since Envoy Client v0.1-alpha
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package envoy.server.processors;
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import static envoy.server.Startup.config;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import envoy.event.ElementOperation;
|
import envoy.event.ElementOperation;
|
||||||
import envoy.event.GroupCreation;
|
import envoy.event.GroupCreation;
|
||||||
|
import envoy.event.GroupCreationResult;
|
||||||
import envoy.event.contact.ContactOperation;
|
import envoy.event.contact.ContactOperation;
|
||||||
import envoy.server.data.Contact;
|
import envoy.server.data.Contact;
|
||||||
import envoy.server.data.PersistenceManager;
|
import envoy.server.data.PersistenceManager;
|
||||||
@ -25,7 +28,10 @@ public final class GroupCreationProcessor implements ObjectProcessor<GroupCreati
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(GroupCreation groupCreation, long socketID, ObjectWriteProxy writeProxy) {
|
public void process(GroupCreation groupCreation, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
envoy.server.data.Group group = new envoy.server.data.Group();
|
// Don't allow the creation of groups if manually disabled
|
||||||
|
writeProxy.write(socketID, new GroupCreationResult(config.isGroupSupportEnabled()));
|
||||||
|
if (!config.isGroupSupportEnabled()) return;
|
||||||
|
final envoy.server.data.Group group = new envoy.server.data.Group();
|
||||||
group.setName(groupCreation.get());
|
group.setName(groupCreation.get());
|
||||||
group.setContacts(new HashSet<>());
|
group.setContacts(new HashSet<>());
|
||||||
groupCreation.getInitialMemberIDs().stream().map(persistenceManager::getUserByID).forEach(group.getContacts()::add);
|
groupCreation.getInitialMemberIDs().stream().map(persistenceManager::getUserByID).forEach(group.getContacts()::add);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package envoy.server.processors;
|
package envoy.server.processors;
|
||||||
|
|
||||||
import static envoy.data.Message.MessageStatus.*;
|
import static envoy.data.Message.MessageStatus.*;
|
||||||
|
import static envoy.server.Startup.config;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -10,6 +11,7 @@ import javax.persistence.EntityExistsException;
|
|||||||
|
|
||||||
import envoy.data.GroupMessage;
|
import envoy.data.GroupMessage;
|
||||||
import envoy.event.MessageStatusChange;
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.event.NoAttachments;
|
||||||
import envoy.server.data.PersistenceManager;
|
import envoy.server.data.PersistenceManager;
|
||||||
import envoy.server.net.ConnectionManager;
|
import envoy.server.net.ConnectionManager;
|
||||||
import envoy.server.net.ObjectWriteProxy;
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
@ -47,17 +49,29 @@ public final class GroupMessageProcessor implements ObjectProcessor<GroupMessage
|
|||||||
writeProxy.write(socketID, new MessageStatusChange(groupMessage));
|
writeProxy.write(socketID, new MessageStatusChange(groupMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// message attachment will be automatically removed if disabled in config
|
||||||
|
final var groupMessageServer = new envoy.server.data.GroupMessage(groupMessage, Instant.now());
|
||||||
|
// Telling the server to reload the message without the attachment and telling
|
||||||
|
// the client not to send anymore attachments
|
||||||
|
if (!config.isAttachmentSupportEnabled() && groupMessage.hasAttachment()) {
|
||||||
|
groupMessage = groupMessageServer.toCommon();
|
||||||
|
writeProxy.write(socketID, new NoAttachments());
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is needed unfortunately because of f***ing lambda restrictions ("must be
|
||||||
|
// fINaL oR EFfEcTivELy FiNAl")
|
||||||
|
final var groupMessageCopy = groupMessage;
|
||||||
// Deliver the message to the recipients that are online
|
// Deliver the message to the recipients that are online
|
||||||
writeProxy.writeToOnlineContacts(
|
writeProxy.writeToOnlineContacts(
|
||||||
persistenceManager.getGroupByID(groupMessage.getRecipientID())
|
persistenceManager.getGroupByID(groupMessageCopy.getRecipientID())
|
||||||
.getContacts()
|
.getContacts()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(c -> c.getID() != groupMessage.getSenderID()),
|
.filter(c -> c.getID() != groupMessageCopy.getSenderID()),
|
||||||
groupMessage);
|
groupMessageCopy);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PersistenceManager.getInstance().addMessage(new envoy.server.data.GroupMessage(groupMessage, Instant.now()));
|
PersistenceManager.getInstance().addMessage(groupMessageServer);
|
||||||
} catch (EntityExistsException e) {
|
} catch (final EntityExistsException e) {
|
||||||
logger.warning("Received a groupMessage with an ID that already exists");
|
logger.warning("Received a groupMessage with an ID that already exists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package envoy.server.processors;
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import static envoy.server.Startup.config;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -7,6 +9,7 @@ import javax.persistence.EntityExistsException;
|
|||||||
|
|
||||||
import envoy.data.Message;
|
import envoy.data.Message;
|
||||||
import envoy.event.MessageStatusChange;
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.event.NoAttachments;
|
||||||
import envoy.server.data.PersistenceManager;
|
import envoy.server.data.PersistenceManager;
|
||||||
import envoy.server.net.ConnectionManager;
|
import envoy.server.net.ConnectionManager;
|
||||||
import envoy.server.net.ObjectWriteProxy;
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
@ -35,6 +38,11 @@ public final class MessageProcessor implements ObjectProcessor<Message> {
|
|||||||
|
|
||||||
// Convert to server message
|
// Convert to server message
|
||||||
final var serverMessage = new envoy.server.data.Message(message);
|
final var serverMessage = new envoy.server.data.Message(message);
|
||||||
|
// Telling the server to reload the message without the attachment
|
||||||
|
if (!config.isAttachmentSupportEnabled() && message.hasAttachment()) {
|
||||||
|
message = serverMessage.toCommon();
|
||||||
|
writeProxy.write(socketID, new NoAttachments());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -54,7 +62,7 @@ public final class MessageProcessor implements ObjectProcessor<Message> {
|
|||||||
// Note that the exact time stamp might differ slightly
|
// Note that the exact time stamp might differ slightly
|
||||||
writeProxy.write(socketID, new MessageStatusChange(message));
|
writeProxy.write(socketID, new MessageStatusChange(message));
|
||||||
}
|
}
|
||||||
} catch (EntityExistsException e) {
|
} catch (final EntityExistsException e) {
|
||||||
logger.log(Level.WARNING, "Received " + message + " with an ID that already exists!");
|
logger.log(Level.WARNING, "Received " + message + " with an ID that already exists!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
enter-to-stop=true
|
enter-to-stop=true
|
||||||
|
enableAttachments=true
|
||||||
|
enableGroups=true
|
||||||
enableIssueReporting=true
|
enableIssueReporting=true
|
||||||
# git.kske.dev config
|
# git.kske.dev config
|
||||||
issueCreationURL=https://git.kske.dev/api/v1/repos/zdm/envoy/issues?access_token=6d8ec2a72d64cbaf6319434aa2e7caf0130701b3
|
issueCreationURL=https://git.kske.dev/api/v1/repos/zdm/envoy/issues?access_token=6d8ec2a72d64cbaf6319434aa2e7caf0130701b3
|
||||||
|
Reference in New Issue
Block a user