diff options
Diffstat (limited to 'juick-server/src/main')
3 files changed, 21 insertions, 4 deletions
diff --git a/juick-server/src/main/java/com/juick/ApiServer.java b/juick-server/src/main/java/com/juick/ApiServer.java index 8b5af8ba..cdd8bb20 100644 --- a/juick-server/src/main/java/com/juick/ApiServer.java +++ b/juick-server/src/main/java/com/juick/ApiServer.java @@ -6,9 +6,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @EnableAutoConfiguration(exclude = { MailSenderAutoConfiguration.class }) +@ComponentScan(basePackages = {"com.juick.server", "com.juick.service"}) public class ApiServer extends SpringBootServletInitializer { @Override diff --git a/juick-server/src/main/java/com/juick/server/CommandsManager.java b/juick-server/src/main/java/com/juick/server/CommandsManager.java index 9178dbb9..6458382f 100644 --- a/juick-server/src/main/java/com/juick/server/CommandsManager.java +++ b/juick-server/src/main/java/com/juick/server/CommandsManager.java @@ -466,7 +466,7 @@ public class CommandsManager { tagService.updateTags(mid, messageTags); return CommandResult.fromString("Tags are updated"); } else { - String attachmentType = StringUtils.isNotEmpty(attachment.toString()) ? attachment.toString().substring(attachment.toString().length() - 3) : null; + String attachmentType = attachment != null && StringUtils.isNotEmpty(attachment.toString()) ? attachment.toString().substring(attachment.toString().length() - 3) : null; int newrid = messagesService.createReply(mid, rid, user.getUid(), txt, attachmentType); if (StringUtils.isNotEmpty(attachmentType)) { String attachmentFName = attachment.getScheme().equals("juick") ? attachment.getHost() diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java index 406294a1..40cf347a 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java @@ -36,6 +36,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -95,7 +96,6 @@ public class XMPPConnection implements StanzaListener, NotificationListener { private CommandsManager commandsManager; @Value("${xmppbot_jid:juick@localhost}") private Jid jid; - @Value("${componentname:localhost}") private String componentName; @Value("${component_port:5347}") @@ -201,6 +201,17 @@ public class XMPPConnection implements StanzaListener, NotificationListener { messagesService.getMessage(jmsg.getMid()))); } } + } else { + String attachment = StringUtils.EMPTY; + OobX oobX = message.getExtension(OobX.class); + if (oobX != null) { + attachment = oobX.getUri().toString(); + } + try { + serverManager.processMessage(userService.getUserByUID(NumberUtils.toInt(message.getFrom().getLocal(), 0)).orElse(new User()), message.getBody(), attachment); + } catch (Exception e1) { + logger.warn("message exception", e1); + } } } else if (jid.getDomain().endsWith(jid.getDomain()) && (jid.getDomain().equals(this.jid.getDomain()) || jid.getDomain().endsWith("." + jid.getDomain()))) { @@ -607,7 +618,11 @@ public class XMPPConnection implements StanzaListener, NotificationListener { if (username.equals(jid.getLocal())) { try { OobX oobX = msg.getExtension(OobX.class); - incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), oobX.getUri()); + if (oobX != null) { + incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), oobX.getUri()); + } else { + incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), null); + } } catch (Exception e) { return; } @@ -669,7 +684,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { int mid = messagesService.createMessage(user_from.getUid(), body, attachmentType, tags); subscriptionService.subscribeMessage(mid, user_from.getUid()); if (StringUtils.isNotEmpty(attachmentType)) { - String attachmentFName = attachment.getScheme().equals("juick") ? attachment.getPath() + String attachmentFName = attachment.getScheme().equals("juick") ? attachment.getHost() : HttpUtils.downloadImage(attachment.toURL(), tmpDir); String fname = String.format("%d.%s", mid, attachmentType); ImageUtils.saveImageWithPreviews(attachmentFName, fname, tmpDir, imgDir); |