Apply suggestions from code review (not everything)
Co-authored-by: CyB3RC0nN0R <CyB3RC0nN0R@users.noreply.github.com>
This commit is contained in:
parent
83ddc02187
commit
e33bc726ac
@ -14,16 +14,7 @@ import envoy.server.data.PersistenceManager;
|
|||||||
import envoy.server.net.ConnectionManager;
|
import envoy.server.net.ConnectionManager;
|
||||||
import envoy.server.net.ObjectMessageProcessor;
|
import envoy.server.net.ObjectMessageProcessor;
|
||||||
import envoy.server.net.ObjectMessageReader;
|
import envoy.server.net.ObjectMessageReader;
|
||||||
import envoy.server.processors.ContactOperationProcessor;
|
import envoy.server.processors.*;
|
||||||
import envoy.server.processors.ContactSearchProcessor;
|
|
||||||
import envoy.server.processors.GroupCreationProcessor;
|
|
||||||
import envoy.server.processors.GroupMessageProcessor;
|
|
||||||
import envoy.server.processors.GroupMessageStatusChangeProcessor;
|
|
||||||
import envoy.server.processors.IDGeneratorRequestProcessor;
|
|
||||||
import envoy.server.processors.LoginCredentialProcessor;
|
|
||||||
import envoy.server.processors.MessageProcessor;
|
|
||||||
import envoy.server.processors.MessageStatusChangeProcessor;
|
|
||||||
import envoy.server.processors.UserStatusChangeProcessor;
|
|
||||||
import envoy.util.EnvoyLog;
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,12 +4,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.ElementCollection;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.NamedQuery;
|
|
||||||
import javax.persistence.Temporal;
|
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
|
|
||||||
import envoy.data.Group;
|
import envoy.data.Group;
|
||||||
|
|
||||||
|
@ -21,8 +21,9 @@ import envoy.server.net.ObjectWriteProxy;
|
|||||||
*/
|
*/
|
||||||
public class GroupMessageStatusChangeProcessor implements ObjectProcessor<GroupMessageStatusChange> {
|
public class GroupMessageStatusChangeProcessor implements ObjectProcessor<GroupMessageStatusChange> {
|
||||||
|
|
||||||
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
private final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(GroupMessageStatusChange input, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
public void process(GroupMessageStatusChange input, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package envoy.server.processors;
|
package envoy.server.processors;
|
||||||
|
|
||||||
import static envoy.data.User.UserStatus.ONLINE;
|
import static envoy.data.User.UserStatus.ONLINE;
|
||||||
import static envoy.event.HandshakeRejection.INTERNAL_ERROR;
|
import static envoy.event.HandshakeRejection.*;
|
||||||
import static envoy.event.HandshakeRejection.USERNAME_TAKEN;
|
|
||||||
import static envoy.event.HandshakeRejection.WRONG_PASSWORD_OR_USER;
|
|
||||||
import static envoy.event.HandshakeRejection.WRONG_VERSION;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -122,7 +119,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
|||||||
writeProxy.write(socketID, user.toCommon());
|
writeProxy.write(socketID, user.toCommon());
|
||||||
|
|
||||||
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
||||||
pendingMessages.removeIf(m -> m instanceof GroupMessage);
|
pendingMessages.removeIf(GroupMessage.class::isInstance);
|
||||||
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
||||||
|
|
||||||
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user);
|
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user);
|
||||||
@ -161,9 +158,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
|||||||
(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.RECEIVED, LocalDateTime.now(),
|
(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.RECEIVED, LocalDateTime.now(),
|
||||||
connectionManager.getUserIdBySocketID(socketID))));
|
connectionManager.getUserIdBySocketID(socketID))));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Maybe Try Catch block is not necessarily needed but if so write proper
|
logger.log(Level.WARNING, "Could not deliver group message status changes", e);
|
||||||
// logger statement here.
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) {
|
if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) {
|
||||||
|
@ -34,7 +34,7 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
|||||||
public void process(Message message, long socketID, ObjectWriteProxy writeProxy) {
|
public void process(Message message, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
// Makes sure, that there are no groupMessages processed here, because
|
// Makes sure, that there are no groupMessages processed here, because
|
||||||
// groupMessage is a subclass of message.
|
// groupMessage is a subclass of message.
|
||||||
if (message.getClass().equals(envoy.data.GroupMessage.class)) {
|
if (message instanceof envoy.data.GroupMessage)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message.nextStatus();
|
message.nextStatus();
|
||||||
|
@ -26,7 +26,7 @@ public class MessageStatusChangeProcessor implements ObjectProcessor<MessageStat
|
|||||||
@Override
|
@Override
|
||||||
public void process(MessageStatusChange statusChange, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
public void process(MessageStatusChange statusChange, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
// Filtering out subclass objects, which should not be processed here.
|
// Filtering out subclass objects, which should not be processed here.
|
||||||
if (statusChange.getClass().equals(GroupMessageStatusChange.class)) return;
|
if (statusChange instanceof GroupMessageStatusChange)) return;
|
||||||
// Any other status than READ is not supposed to be sent to the server
|
// Any other status than READ is not supposed to be sent to the server
|
||||||
if (statusChange.get() != MessageStatus.READ) throw new IOException(new EnvoyException(statusChange + " has an invalid status"));
|
if (statusChange.get() != MessageStatus.READ) throw new IOException(new EnvoyException(statusChange + " has an invalid status"));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user