aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/controllers')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java (renamed from juick-www/src/main/java/com/juick/www/controllers/Messages.java)2
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java13
2 files changed, 6 insertions, 9 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/Messages.java b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java
index 65e122a6..e6662c4e 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/Messages.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java
@@ -52,7 +52,7 @@ import java.util.stream.Collectors;
* @author Ugnich Anton
*/
@Controller
-public class Messages {
+public class MessagesWWW {
@Inject
private UserService userService;
@Inject
diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
index f8a11d82..6e16ae50 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
@@ -16,13 +16,10 @@
*/
package com.juick.www.controllers;
-import com.juick.Status;
-import com.juick.Tag;
import com.juick.User;
import com.juick.server.helpers.AnonymousUser;
import com.juick.server.util.*;
import com.juick.service.*;
-import com.juick.util.MessageUtils;
import com.juick.www.WebApp;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
@@ -34,7 +31,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.stanza.model.Message;
@@ -47,7 +43,6 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.List;
import java.util.stream.Collectors;
/**
@@ -76,6 +71,8 @@ public class NewMessage {
private String imgDir;
@Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
private String tmpDir;
+ @Value("${xmppbot_jid:juick@localhost}")
+ private Jid botJid;
private static final Logger logger = LoggerFactory.getLogger(NewMessage.class);
@@ -247,11 +244,11 @@ public class NewMessage {
if (visitor.getUid() == 0 || visitor.isBanned()) {
throw new HttpForbiddenException();
}
- String body = bodyParam.replace("\r", StringUtils.EMPTY);
+ String body = StringUtils.isNotEmpty(bodyParam) ? bodyParam.replace("\r", StringUtils.EMPTY) : StringUtils.EMPTY;
String attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir);
- if (StringUtils.isBlank(attachmentFName) && img != null && img.length() > 10) {
+ if (StringUtils.isBlank(attachmentFName) && StringUtils.isNotBlank(img)) {
try {
URL imgUrl = new URL(img);
attachmentFName = HttpUtils.downloadImage(imgUrl, tmpDir);
@@ -263,7 +260,7 @@ public class NewMessage {
Message msg = new Message();
msg.setType(Message.Type.CHAT);
msg.setFrom(Jid.of(String.valueOf(visitor.getUid()), "uid.juick.com", "perl"));
- msg.setTo(Jid.of("juick@juick.com/Juick"));
+ msg.setTo(botJid);
msg.setBody(body);
try {
if (StringUtils.isNotEmpty(attachmentFName)) {