diff options
-rw-r--r-- | build.gradle | 1 | ||||
-rw-r--r-- | juick-notifications/build.gradle | 1 | ||||
-rw-r--r-- | juick-server-xmpp/build.gradle | 5 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/CommandsManager.java (renamed from juick-server/src/main/java/com/juick/server/CommandsManager.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/NotificationListener.java (renamed from juick-server/src/main/java/com/juick/server/NotificationListener.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java (renamed from juick-server/src/main/java/com/juick/server/XMPPConnection.java) | 15 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java (renamed from juick-server/src/main/java/com/juick/server/XMPPServer.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/CommandResult.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/helpers/CommandResult.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/XMPPStatus.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/helpers/XMPPStatus.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/annotation/UserCommand.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/helpers/annotation/UserCommand.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/Stream.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/Stream.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamHandler.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/StreamHandler.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamNamespaces.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/StreamNamespaces.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XMPPError.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/XMPPError.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XmlUtils.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/router/XmlUtils.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/CacheEntry.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/CacheEntry.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/Connection.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/Connection.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionListener.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionListener.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionOut.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionOut.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/DNSQueries.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/DNSQueries.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/StanzaListener.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/StanzaListener.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/util/DialbackUtils.java (renamed from juick-server/src/main/java/com/juick/server/xmpp/s2s/util/DialbackUtils.java) | 0 | ||||
-rw-r--r-- | juick-server-xmpp/src/main/resources/juick.png (renamed from juick-server/src/main/resources/juick.png) | bin | 2324 -> 2324 bytes | |||
-rw-r--r-- | juick-server/build.gradle | 1 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/MessengerManager.java | 4 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/ServerManager.java | 10 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/TelegramBotManager.java | 6 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/WebsocketManager.java | 4 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/Post.java | 8 | ||||
-rw-r--r-- | juick-www/build.gradle | 2 | ||||
-rw-r--r-- | juick-www/src/main/java/com/juick/Application.java | 1 | ||||
-rw-r--r-- | juick-www/src/test/java/com/juick/WebAppTests.java | 19 | ||||
-rw-r--r-- | settings.gradle | 2 |
37 files changed, 39 insertions, 40 deletions
diff --git a/build.gradle b/build.gradle index a8452a7e..3361e933 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,6 @@ allprojects { maven { url "https://jitpack.io" } maven { url "https://repository.apache.org/content/repositories/snapshots/" } } - apply plugin: 'io.spring.dependency-management' dependencyManagement { imports { diff --git a/juick-notifications/build.gradle b/juick-notifications/build.gradle index 83059bbe..28290424 100644 --- a/juick-notifications/build.gradle +++ b/juick-notifications/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'java' -apply plugin: 'war' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' diff --git a/juick-server-xmpp/build.gradle b/juick-server-xmpp/build.gradle new file mode 100644 index 00000000..e1e96723 --- /dev/null +++ b/juick-server-xmpp/build.gradle @@ -0,0 +1,5 @@ +apply plugin: 'java' + +dependencies { + compile project(':juick-common') +}
\ No newline at end of file diff --git a/juick-server/src/main/java/com/juick/server/CommandsManager.java b/juick-server-xmpp/src/main/java/com/juick/server/CommandsManager.java index 6458382f..6458382f 100644 --- a/juick-server/src/main/java/com/juick/server/CommandsManager.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/CommandsManager.java diff --git a/juick-server/src/main/java/com/juick/server/NotificationListener.java b/juick-server-xmpp/src/main/java/com/juick/server/NotificationListener.java index f6330570..f6330570 100644 --- a/juick-server/src/main/java/com/juick/server/NotificationListener.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/NotificationListener.java diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java index 4be4a5ba..a60b506d 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java @@ -126,8 +126,6 @@ public class XMPPConnection implements StanzaListener, NotificationListener { @Inject private ExecutorService service; @Inject - private ServerManager serverManager; - @Inject private ApplicationEventPublisher applicationEventPublisher; @PostConstruct @@ -210,7 +208,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { attachment = oobX.getUri().toString(); } try { - serverManager.processMessage(userService.getUserByUID(NumberUtils.toInt(message.getFrom().getLocal(), 0)).orElse(new User()), message.getBody(), attachment); + processMessage(userService.getUserByUID(NumberUtils.toInt(message.getFrom().getLocal(), 0)).orElse(new User()), message.getBody(), attachment); } catch (Exception e1) { logger.warn("message exception", e1); } @@ -254,7 +252,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { if (st.getStatus().equals(FileTransfer.Status.COMPLETED)) { logger.info("transfer completed"); try { - serverManager.processMessage(userService.getUserByJID(e.getInitiator().toEscapedString()), e.getDescription(), targetFilename); + processMessage(userService.getUserByJID(e.getInitiator().toEscapedString()), e.getDescription(), targetFilename); } catch (Exception e1) { logger.error("ft error", e1); } @@ -696,6 +694,15 @@ public class XMPPConnection implements StanzaListener, NotificationListener { return msg; } } + public com.juick.Message processMessage(User visitor, String body, String attachmentName) throws Exception { + if (StringUtils.isNotEmpty(attachmentName)) { + URI httpUri = URI.create(attachmentName); + if (!httpUri.isAbsolute()) { + attachmentName = String.format("juick://%s", attachmentName); + } + } + return incomingMessageJuick(visitor, Jid.of(String.valueOf(visitor.getUid()), "uid.juick.com", "perl"), body, URI.create(attachmentName)); + } @Override public void stanzaReceived(Stanza xmlValue) { diff --git a/juick-server/src/main/java/com/juick/server/XMPPServer.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java index c291202d..c291202d 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPServer.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/helpers/CommandResult.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/CommandResult.java index f952b579..f952b579 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/helpers/CommandResult.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/CommandResult.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/helpers/XMPPStatus.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/XMPPStatus.java index 7978ceb3..7978ceb3 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/helpers/XMPPStatus.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/XMPPStatus.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/helpers/annotation/UserCommand.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/annotation/UserCommand.java index 383383c9..383383c9 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/helpers/annotation/UserCommand.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/helpers/annotation/UserCommand.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/Stream.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/Stream.java index 7532443c..7532443c 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/Stream.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/Stream.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java index 5e2f6f82..5e2f6f82 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java index 7eacfc94..7eacfc94 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamHandler.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamHandler.java index 43836c2d..43836c2d 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamHandler.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamHandler.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamNamespaces.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamNamespaces.java index 1b9b1965..1b9b1965 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamNamespaces.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamNamespaces.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPError.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XMPPError.java index 0cf9a3bc..0cf9a3bc 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPError.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XMPPError.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java index a262e941..a262e941 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/XmlUtils.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XmlUtils.java index 7579489f..7579489f 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/router/XmlUtils.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/XmlUtils.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/CacheEntry.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/CacheEntry.java index 33e875bd..33e875bd 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/CacheEntry.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/CacheEntry.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/Connection.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/Connection.java index 6bf61169..6bf61169 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/Connection.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/Connection.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java index 9ee81d4d..9ee81d4d 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionListener.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionListener.java index fde7a0e7..fde7a0e7 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionListener.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionListener.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionOut.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionOut.java index e3bd53e9..e3bd53e9 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionOut.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/ConnectionOut.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/DNSQueries.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/DNSQueries.java index 1367d333..1367d333 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/DNSQueries.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/DNSQueries.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/StanzaListener.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/StanzaListener.java index 6932298f..6932298f 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/StanzaListener.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/StanzaListener.java diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/util/DialbackUtils.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/util/DialbackUtils.java index d25dbad8..d25dbad8 100644 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/util/DialbackUtils.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/s2s/util/DialbackUtils.java diff --git a/juick-server/src/main/resources/juick.png b/juick-server-xmpp/src/main/resources/juick.png Binary files differindex c85ef2c4..c85ef2c4 100644 --- a/juick-server/src/main/resources/juick.png +++ b/juick-server-xmpp/src/main/resources/juick.png diff --git a/juick-server/build.gradle b/juick-server/build.gradle index bb4d68ae..15e015ed 100644 --- a/juick-server/build.gradle +++ b/juick-server/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'org.springframework.boot' dependencies { compile project(':juick-server-jdbc') + compile project(':juick-server-xmpp') compile ('org.springframework.boot:spring-boot-starter-security') providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") providedRuntime 'com.h2database:h2:1.4.196' diff --git a/juick-server/src/main/java/com/juick/server/MessengerManager.java b/juick-server/src/main/java/com/juick/server/MessengerManager.java index adef1e22..ca206bd4 100644 --- a/juick-server/src/main/java/com/juick/server/MessengerManager.java +++ b/juick-server/src/main/java/com/juick/server/MessengerManager.java @@ -50,7 +50,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> { @Inject private MessengerService messengerService; @Inject - private ServerManager serverManager; + private XMPPConnection xmppConnection; @Value("${fb_page_access_token:12345678}") private String facebookPageAccessToken; @@ -97,7 +97,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> { logger.info("Received text message from '{}' at '{}' with content: {} (mid: {})", senderId, timestamp, text, messageId); try { - serverManager.processMessage(user_from, text, null); + xmppConnection.processMessage(user_from, text, null); } catch (Exception e) { logger.warn("messenger error", e); } diff --git a/juick-server/src/main/java/com/juick/server/ServerManager.java b/juick-server/src/main/java/com/juick/server/ServerManager.java index 6cac270c..40de9d3e 100644 --- a/juick-server/src/main/java/com/juick/server/ServerManager.java +++ b/juick-server/src/main/java/com/juick/server/ServerManager.java @@ -57,16 +57,6 @@ public class ServerManager implements ApplicationListener<MessageEvent> { @Inject private XMPPConnection router; - public com.juick.Message processMessage(User visitor, String body, String attachmentName) throws Exception { - if (StringUtils.isNotEmpty(attachmentName)) { - URI httpUri = URI.create(attachmentName); - if (!httpUri.isAbsolute()) { - attachmentName = String.format("juick://%s", attachmentName); - } - } - return router.incomingMessageJuick(visitor, Jid.of(String.valueOf(visitor.getUid()), "uid.juick.com", "perl"), body, URI.create(attachmentName)); - } - private void onJuickPM(final int uid_to, final com.juick.Message jmsg) { try { String json = jsonMapper.writeValueAsString(jmsg); diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java index c1ccc8ff..020d2433 100644 --- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java +++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java @@ -79,7 +79,7 @@ public class TelegramBotManager implements NotificationListener { @Inject private UserService userService; @Inject - private ServerManager serverManager; + private XMPPConnection xmppConnection; @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}") private String tmpDir; @@ -183,7 +183,7 @@ public class TelegramBotManager implements NotificationListener { int rid = Integer.valueOf(uriComponents.getFragment()); prefix = String.format("#%d/%d ", mid, rid); } - serverManager.processMessage(user_from, prefix + text, attachment); + xmppConnection.processMessage(user_from, prefix + text, attachment); telegramNotify(message.from().id().longValue(), "Reply sent", StringUtils.EMPTY); } else { logger.warn("invalid path: {}", path); @@ -200,7 +200,7 @@ public class TelegramBotManager implements NotificationListener { "Can not reply to this message", replyMessage.messageId(), StringUtils.EMPTY); } } else { - serverManager.processMessage(user_from, text, attachment); + xmppConnection.processMessage(user_from, text, attachment); telegramNotify(message.from().id().longValue(), "Message sent", StringUtils.EMPTY); } } diff --git a/juick-server/src/main/java/com/juick/server/WebsocketManager.java b/juick-server/src/main/java/com/juick/server/WebsocketManager.java index 309f605c..498bf064 100644 --- a/juick-server/src/main/java/com/juick/server/WebsocketManager.java +++ b/juick-server/src/main/java/com/juick/server/WebsocketManager.java @@ -70,7 +70,7 @@ public class WebsocketManager extends TextWebSocketHandler { @Inject private ObjectMapper jsonMapper; @Inject - private ServerManager serverManager; + private XMPPConnection xmppConnection; @Override @@ -151,7 +151,7 @@ public class WebsocketManager extends TextWebSocketHandler { Message draft = jsonMapper.readValue(message.asBytes(), Message.class); if (draft.getUser() != null && (draft.getText() != null || draft.getAttachment() != null)) { String attachmentFileName = draft.getAttachment() == null ? "" : draft.getAttachment().getUrl(); - serverManager.processMessage(draft.getUser(), draft.getText(), attachmentFileName); + xmppConnection.processMessage(draft.getUser(), draft.getText(), attachmentFileName); } } catch (Exception e) { throw new HttpBadRequestException(); diff --git a/juick-server/src/main/java/com/juick/server/api/Post.java b/juick-server/src/main/java/com/juick/server/api/Post.java index 3d9703fd..312df52d 100644 --- a/juick-server/src/main/java/com/juick/server/api/Post.java +++ b/juick-server/src/main/java/com/juick/server/api/Post.java @@ -71,7 +71,7 @@ public class Post { @Inject private UserService userService; @Inject - private ServerManager serverManager; + private XMPPConnection xmppConnection; @Inject private MessagesService messagesService; @Inject @@ -112,7 +112,7 @@ public class Post { throw new HttpBadRequestException(); } } - serverManager.processMessage(visitor, body, attachmentFName); + xmppConnection.processMessage(visitor, body, attachmentFName); } @PostMapping("/upload") public String doUploadFile(@RequestParam(required = true) MultipartFile attach) { @@ -169,7 +169,7 @@ public class Post { } } - return serverManager.processMessage(visitor, body, attachmentFName); + return xmppConnection.processMessage(visitor, body, attachmentFName); } Session session = Session.getDefaultInstance(new Properties()); @@ -231,7 +231,7 @@ public class Post { body[0] = rid > 0 ? String.format("#%d/%d %s", mid, rid, body[0]) : String.format("#%d %s", mid, body[0]); } - serverManager.processMessage(visitor, body[0], attachmentFName[0]); + xmppConnection.processMessage(visitor, body[0], attachmentFName[0]); } else { logger.info("not registered: {}", from); } diff --git a/juick-www/build.gradle b/juick-www/build.gradle index 5cad742f..cf7da5bd 100644 --- a/juick-www/build.gradle +++ b/juick-www/build.gradle @@ -23,7 +23,7 @@ apply plugin: 'org.springframework.boot' dependencies { compile project(':juick-server-jdbc') - providedCompile project(':juick-server') + providedCompile project(':juick-server-xmpp') compile 'com.github.ben-manes.caffeine:caffeine:2.6.2' compile("org.springframework.boot:spring-boot-starter-cache") compile ('org.springframework.boot:spring-boot-starter-security') diff --git a/juick-www/src/main/java/com/juick/Application.java b/juick-www/src/main/java/com/juick/Application.java index a7a7a654..cb132ae9 100644 --- a/juick-www/src/main/java/com/juick/Application.java +++ b/juick-www/src/main/java/com/juick/Application.java @@ -5,7 +5,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Primary; import org.springframework.transaction.annotation.EnableTransactionManagement; @SpringBootApplication diff --git a/juick-www/src/test/java/com/juick/WebAppTests.java b/juick-www/src/test/java/com/juick/WebAppTests.java index f644bef8..a9eb6926 100644 --- a/juick-www/src/test/java/com/juick/WebAppTests.java +++ b/juick-www/src/test/java/com/juick/WebAppTests.java @@ -23,10 +23,10 @@ import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.css.StyleElement; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.juick.server.CommandsManager; import com.juick.server.XMPPConnection; -import com.juick.server.xmpp.router.XMPPRouter; import com.juick.server.XMPPServer; -import com.juick.server.configuration.ApiAppConfiguration; +import com.juick.server.xmpp.router.XMPPRouter; import com.juick.service.*; import com.juick.util.MessageUtils; import com.juick.www.WebApp; @@ -39,11 +39,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.mock.web.MockMultipartFile; @@ -76,7 +74,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @AutoConfigureMockMvc -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {Application.class, XMPPRouter.class}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {Application.class, XMPPRouter.class, XMPPServer.class, XMPPConnection.class, CommandsManager.class}) public class WebAppTests { @MockBean private ImagesService imagesService; @@ -98,6 +96,12 @@ public class WebAppTests { private JdbcTemplate jdbcTemplate; @Inject private SubscriptionService subscriptionService; + @Inject + private XMPPServer xmpp; + @Inject + private XMPPConnection routerConnection; + @Inject + private XMPPRouter xmppRouter; @Inject private PebbleEngine pebbleEngine; @@ -239,11 +243,6 @@ public class WebAppTests { } @Test public void postMessageTests() throws Exception { - ConfigurableApplicationContext context = new SpringApplicationBuilder( - ApiServer.class) - .properties("server.port=8081") - .run(); - XMPPServer xmpp = context.getBean(XMPPServer.class); assertThat(xmpp.getInConnections().size(), is(0)); mockMvc.perform(post("/post2").param("body", "yo")).andExpect(redirectedUrl("http://localhost/login")); MvcResult loginResult = mockMvc.perform(post("/login") diff --git a/settings.gradle b/settings.gradle index 766c8337..515091f3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ rootProject.name = "Juick" -include ':juick-common', ':juick-server-jdbc', ':juick-server', ':juick-www', ':juick-notifications' +include ':juick-common', ':juick-server-jdbc', ':juick-server-xmpp', ':juick-server', ':juick-www', ':juick-notifications' |