diff --git a/src/main/java/envoy/server/Startup.java b/src/main/java/envoy/server/Startup.java
index 8ccbe5e..f4e5bc7 100644
--- a/src/main/java/envoy/server/Startup.java
+++ b/src/main/java/envoy/server/Startup.java
@@ -10,7 +10,12 @@ import envoy.server.data.ConfigItem;
import envoy.server.database.PersistenceManager;
import envoy.server.net.ObjectMessageProcessor;
import envoy.server.net.ObjectMessageReader;
-import envoy.server.processors.*;
+import envoy.server.processors.ContactsRequestProcesor;
+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;
/**
* Starts the server.
@@ -38,6 +43,7 @@ public class Startup {
processors.add(new MessageStatusChangeProcessor());
processors.add(new UserStatusChangeProcessor());
processors.add(new IdGeneratorRequestProcessor());
+ processors.add(new ContactsRequestProcesor());
Server server = new Server(8080, () -> new ObjectMessageReader(), new ObjectMessageProcessor(processors));
initializeCurrentMessageId();
diff --git a/src/main/java/envoy/server/database/PersistenceManager.java b/src/main/java/envoy/server/database/PersistenceManager.java
index 32a5219..91c7b19 100644
--- a/src/main/java/envoy/server/database/PersistenceManager.java
+++ b/src/main/java/envoy/server/database/PersistenceManager.java
@@ -177,7 +177,7 @@ public class PersistenceManager {
}
public List searchUsers(String searchPhrase) {
- return entityManager.createNamedQuery("searchUsers").setParameter("searchPhrase", searchPhrase).getResultList();
+ return entityManager.createNamedQuery("searchUsers").setParameter("searchPhrase", searchPhrase + "%").getResultList();
}
/**
diff --git a/src/main/java/envoy/server/processors/ContactsRequestProcesor.java b/src/main/java/envoy/server/processors/ContactsRequestProcesor.java
index 7757345..13bda86 100644
--- a/src/main/java/envoy/server/processors/ContactsRequestProcesor.java
+++ b/src/main/java/envoy/server/processors/ContactsRequestProcesor.java
@@ -3,6 +3,7 @@ package envoy.server.processors;
import java.io.IOException;
import java.util.stream.Collectors;
+import envoy.data.Contacts;
import envoy.event.ContactsRequest;
import envoy.server.ObjectProcessor;
import envoy.server.database.PersistenceManager;
@@ -21,11 +22,11 @@ public class ContactsRequestProcesor implements ObjectProcessor
@Override
public void process(ContactsRequest request, long socketId, ObjectWriteProxy writeProxy) throws IOException {
writeProxy.write(socketId,
- PersistenceManager.getPersistenceManager()
+ new Contacts(PersistenceManager.getPersistenceManager()
.searchUsers(request.get())
.stream()
.map(envoy.server.data.User::toCommonUser)
- .collect(Collectors.toList()));
+ .collect(Collectors.toList())));
}
@Override