diff options
4 files changed, 13 insertions, 18 deletions
diff --git a/juick-common/src/main/java/com/juick/server/util/HttpUtils.java b/juick-common/src/main/java/com/juick/server/util/HttpUtils.java index f86e52c5..e348d6a2 100644 --- a/juick-common/src/main/java/com/juick/server/util/HttpUtils.java +++ b/juick-common/src/main/java/com/juick/server/util/HttpUtils.java @@ -58,7 +58,7 @@ public class HttpUtils { } } } - return URI.create(""); + return URI.create(StringUtils.EMPTY); } public static URI downloadImage(URL url, String tmpDir) throws Exception { URLConnection urlConn; diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java index 40209fad..f0c205d9 100644 --- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java @@ -63,6 +63,7 @@ import rocks.xmpp.extensions.version.SoftwareVersionManager; import rocks.xmpp.extensions.version.model.SoftwareVersion; import rocks.xmpp.util.XmppUtils; +import javax.annotation.Nonnull; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; @@ -200,7 +201,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } } } else { - URI attachment = URI.create(""); + URI attachment = URI.create(StringUtils.EMPTY); OobX oobX = message.getExtension(OobX.class); if (oobX != null) { attachment = oobX.getUri(); @@ -587,26 +588,25 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } return; } - if (StringUtils.isBlank(msg.getBody())) { - return; - } - String username = msg.getTo().getLocal(); User user_from; user_from = userService.getUserByJID(msg.getFrom().asBareJid().toEscapedString()); - URI attachmentURI = URI.create(""); + URI attachmentURI = URI.create(StringUtils.EMPTY); OobX oobX = msg.getExtension(OobX.class); if (oobX != null) { attachmentURI = oobX.getUri(); } incomingMessageJuick(user_from, msg.getFrom(), msg.getBody(), attachmentURI); } - public com.juick.Message incomingMessageJuick(User user_from, Jid from, String command, URI attachment) throws Exception { + public com.juick.Message incomingMessageJuick(User user_from, Jid from, String command, @Nonnull URI attachment) throws Exception { if (user_from == null) { String signuphash = userService.getSignUpHashByJID(from.asBareJid().toEscapedString()); sendReply(from, "Для того, чтобы начать пользоваться сервисом, пожалуйста пройдите быструю регистрацию: http://juick.com/signup?type=xmpp&hash=" + signuphash + "\nЕсли у вас уже есть учетная запись на Juick, вы сможете присоединить этот JabberID к ней.\n\nTo start using Juick, please sign up: http://juick.com/signup?type=xmpp&hash=" + signuphash + "\nIf you already have an account on Juick, you will be proposed to attach this JabberID to your existing account."); return null; } + if (StringUtils.isBlank(command) && attachment.toString().isEmpty()) { + return null; + } int commandlen = command.length(); 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 55330c3d..0de3d882 100644 --- a/juick-server/src/main/java/com/juick/server/MessengerManager.java +++ b/juick-server/src/main/java/com/juick/server/MessengerManager.java @@ -19,17 +19,18 @@ import com.juick.service.MessagesService; import com.juick.service.MessengerService; import com.juick.service.SubscriptionService; import com.juick.service.UserService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; import javax.inject.Inject; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.time.Instant; import java.util.Collections; @@ -97,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, null); + xmppConnection.incomingMessageJuick(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/api/Post.java b/juick-server/src/main/java/com/juick/server/api/Post.java index 7c8fb2ea..1dd18b66 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 @@ -19,9 +19,8 @@ package com.juick.server.api; import com.juick.Status; import com.juick.User; -import com.juick.server.EmailManager; -import com.juick.server.ServerManager; import com.juick.server.CommandsManager; +import com.juick.server.EmailManager; import com.juick.server.XMPPConnection; import com.juick.server.util.*; import com.juick.server.xmpp.helpers.CommandResult; @@ -39,10 +38,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import rocks.xmpp.addr.Jid; -import rocks.xmpp.core.stanza.model.Message; -import rocks.xmpp.extensions.nick.model.Nickname; -import rocks.xmpp.extensions.oob.model.x.OobX; import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; @@ -53,7 +48,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URI; -import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; @@ -66,7 +60,7 @@ import java.util.UUID; */ @RestController public class Post { - private static Logger logger = LoggerFactory.getLogger(ServerManager.class); + private static Logger logger = LoggerFactory.getLogger(Post.class); @Inject private UserService userService; |