aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-30 17:52:53 +0300
committerGravatar Vitaly Takmazov2018-03-30 17:52:53 +0300
commitbda2d764a9c187da5aa8cd74fb8c4a9574d3996e (patch)
tree2d5bc98a5744f8f6a0ec4e7f9893c2355235267c /juick-www/src/main/java
parent7eb13edc1720b13924d7cbe715be67a535f0e02e (diff)
xmpp integration tests
Diffstat (limited to 'juick-www/src/main/java')
-rw-r--r--juick-www/src/main/java/com/juick/Application.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java (renamed from juick-www/src/main/java/com/juick/configuration/SapeConfiguration.java)2
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java (renamed from juick-www/src/main/java/com/juick/configuration/WebSecurityConfig.java)4
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java (renamed from juick-www/src/main/java/com/juick/configuration/WwwAppConfiguration.java)2
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java (renamed from juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java)2
-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
7 files changed, 14 insertions, 14 deletions
diff --git a/juick-www/src/main/java/com/juick/Application.java b/juick-www/src/main/java/com/juick/Application.java
index f8e5d333..a7a7a654 100644
--- a/juick-www/src/main/java/com/juick/Application.java
+++ b/juick-www/src/main/java/com/juick/Application.java
@@ -4,10 +4,13 @@ import org.springframework.boot.SpringApplication;
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
@EnableTransactionManagement
+@ComponentScan(basePackages = {"com.juick.www", "com.juick.service"})
public class Application extends SpringBootServletInitializer {
@Override
diff --git a/juick-www/src/main/java/com/juick/configuration/SapeConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java
index 2630c05b..68ff28d2 100644
--- a/juick-www/src/main/java/com/juick/configuration/SapeConfiguration.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.juick.configuration;
+package com.juick.www.configuration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
diff --git a/juick-www/src/main/java/com/juick/configuration/WebSecurityConfig.java b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
index 92f43e64..909b6cd3 100644
--- a/juick-www/src/main/java/com/juick/configuration/WebSecurityConfig.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.juick.configuration;
+package com.juick.www.configuration;
import com.juick.service.UserService;
import com.juick.service.security.HashParamAuthenticationFilter;
@@ -72,7 +72,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.addFilterAfter(hashParamAuthenticationFilter(), BasicAuthenticationFilter.class);
http
.authorizeRequests()
- .antMatchers("/settings", "/pm/**", "/**/bl", "/_twitter", "/post", "/comment")
+ .antMatchers("/settings", "/pm/**", "/**/bl", "/_twitter", "/post", "/post2", "/comment")
.authenticated()
.anyRequest().permitAll()
.and()
diff --git a/juick-www/src/main/java/com/juick/configuration/WwwAppConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java
index ea585a6f..13a394cb 100644
--- a/juick-www/src/main/java/com/juick/configuration/WwwAppConfiguration.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.juick.configuration;
+package com.juick.www.configuration;
import com.juick.server.configuration.BaseWebConfiguration;
import com.juick.server.configuration.StorageConfiguration;
diff --git a/juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java
index 91f55759..1396f9f9 100644
--- a/juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java
@@ -1,4 +1,4 @@
-package com.juick.configuration;
+package com.juick.www.configuration;
import com.juick.Message;
import org.slf4j.Logger;
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)) {