aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-05 14:03:09 +0300
committerGravatar Vitaly Takmazov2018-04-05 14:03:09 +0300
commit534d3c6f8ab31c0d41e6a6980f8cbc3f25e8d1b9 (patch)
tree9da4ecad27afa9750a6c0369e181e287944473bf /juick-server/src/main
parent2f53f75e584e0522c8f4783bc28df4ad6eb3033d (diff)
server: commands are not depended on xmpp now
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/MessengerManager.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java6
-rw-r--r--juick-server/src/main/java/com/juick/server/WebsocketManager.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Post.java6
4 files changed, 10 insertions, 10 deletions
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 0de3d882..1628afc0 100644
--- a/juick-server/src/main/java/com/juick/server/MessengerManager.java
+++ b/juick-server/src/main/java/com/juick/server/MessengerManager.java
@@ -51,7 +51,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
@Inject
private MessengerService messengerService;
@Inject
- private XMPPConnection xmppConnection;
+ private CommandsManager commandsManager;
@Value("${fb_page_access_token:12345678}")
private String facebookPageAccessToken;
@@ -98,7 +98,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
logger.info("Received text message from '{}' at '{}' with content: {} (mid: {})",
senderId, timestamp, text, messageId);
try {
- xmppConnection.incomingMessageJuick(user_from, null, text, URI.create(StringUtils.EMPTY));
+ commandsManager.processCommand(user_from, null, text, URI.create(StringUtils.EMPTY));
} catch (Exception e) {
logger.warn("messenger error", e);
}
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 9fcf08da..54edb5db 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -80,7 +80,7 @@ public class TelegramBotManager implements NotificationListener {
@Inject
private UserService userService;
@Inject
- private XMPPConnection xmppConnection;
+ private CommandsManager commandsManager;
@Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
private String tmpDir;
@@ -184,7 +184,7 @@ public class TelegramBotManager implements NotificationListener {
int rid = Integer.valueOf(uriComponents.getFragment());
prefix = String.format("#%d/%d ", mid, rid);
}
- xmppConnection.incomingMessageJuick(user_from, null,prefix + text, attachment);
+ commandsManager.processCommand(user_from, null,prefix + text, attachment);
telegramNotify(message.from().id().longValue(), "Reply sent", StringUtils.EMPTY);
} else {
logger.warn("invalid path: {}", path);
@@ -201,7 +201,7 @@ public class TelegramBotManager implements NotificationListener {
"Can not reply to this message", replyMessage.messageId(), StringUtils.EMPTY);
}
} else {
- xmppConnection.incomingMessageJuick(user_from, null, text, attachment);
+ commandsManager.processCommand(user_from, null, 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 fc7035ab..8475fd40 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 XMPPConnection xmppConnection;
+ private CommandsManager commandsManager;
@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();
- xmppConnection.incomingMessageJuick(draft.getUser(), null, draft.getText(), URI.create(attachmentFileName));
+ commandsManager.processCommand(draft.getUser(), null, draft.getText(), URI.create(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 ef0c7dd9..e949dad7 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
@@ -106,7 +106,7 @@ public class Post {
throw new HttpBadRequestException();
}
}
- xmppConnection.incomingMessageJuick(visitor, null, body, attachmentFName);
+ commandsManager.processCommand(visitor, null, body, attachmentFName);
}
@PostMapping("/upload")
public String doUploadFile(@RequestParam(required = true) MultipartFile attach) {
@@ -163,7 +163,7 @@ public class Post {
}
}
- return xmppConnection.incomingMessageJuick(visitor, null, body, attachmentFName);
+ return commandsManager.processCommand(visitor, null, body, attachmentFName).getNewMessage();
}
Session session = Session.getDefaultInstance(new Properties());
@@ -227,7 +227,7 @@ public class Post {
}
URI attachmentUri = StringUtils.isNotEmpty(attachmentFName[0]) ? URI.create(String.format("juick://%s", attachmentFName[0]))
: URI.create(StringUtils.EMPTY);
- xmppConnection.incomingMessageJuick(visitor, null, body[0], attachmentUri);
+ commandsManager.processCommand(visitor, null, body[0], attachmentUri);
} else {
logger.info("not registered: {}", from);
}