aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api/src/main/java/com')
-rw-r--r--juick-api/src/main/java/com/juick/api/EmailManager.java16
-rw-r--r--juick-api/src/main/java/com/juick/api/MessengerManager.java4
-rw-r--r--juick-api/src/main/java/com/juick/api/TelegramBotManager.java2
-rw-r--r--juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java3
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/Post.java3
5 files changed, 18 insertions, 10 deletions
diff --git a/juick-api/src/main/java/com/juick/api/EmailManager.java b/juick-api/src/main/java/com/juick/api/EmailManager.java
index 1c105ef9..c90e7b7a 100644
--- a/juick-api/src/main/java/com/juick/api/EmailManager.java
+++ b/juick-api/src/main/java/com/juick/api/EmailManager.java
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
+import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.mail.MessagingException;
import javax.mail.Multipart;
@@ -29,17 +30,20 @@ import static com.juick.formatters.PlainTextFormatter.formatUrl;
@Component
public class EmailManager implements ApplicationListener<MessageEvent> {
+
+ public static final String MSGID_PATTERN = "\\.|@|<";
+
private static final Logger logger = LoggerFactory.getLogger(EmailManager.class);
@Inject
- EmailService emailService;
+ private EmailService emailService;
@Inject
- SubscriptionService subscriptionService;
+ private SubscriptionService subscriptionService;
@Inject
- MessagesService messagesService;
+ private MessagesService messagesService;
@Inject
- UserService userService;
+ private UserService userService;
@Override
- public void onApplicationEvent(MessageEvent event) {
+ public void onApplicationEvent(@Nonnull MessageEvent event) {
Message msg = event.getMessage();
if (msg.getRid() == 0) {
String subject = String.format("New message from %s", msg.getUser().getName());
@@ -55,7 +59,7 @@ public class EmailManager implements ApplicationListener<MessageEvent> {
}
}
- void emailNotify(String email, String subject, Message msg) {
+ private void emailNotify(String email, String subject, Message msg) {
Properties prop = System.getProperties();
prop.put("mail.smtp.starttls.enable", "true");
Session session = Session.getDefaultInstance(prop);
diff --git a/juick-api/src/main/java/com/juick/api/MessengerManager.java b/juick-api/src/main/java/com/juick/api/MessengerManager.java
index f1babe81..2008144a 100644
--- a/juick-api/src/main/java/com/juick/api/MessengerManager.java
+++ b/juick-api/src/main/java/com/juick/api/MessengerManager.java
@@ -120,7 +120,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
}
}
- void messengerNotify(String messengerUser, String text, String url) {
+ private void messengerNotify(String messengerUser, String text, String url) {
try {
if (!StringUtils.isEmpty(url)) {
final UrlButton showMessage = UrlButton.create("VIEW MESSAGE", new URL(url));
@@ -133,7 +133,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
logger.warn("messenger error", e);
}
}
- void signupNotify(String messengerUser, String hash) throws MalformedURLException, MessengerApiException, MessengerIOException {
+ private void signupNotify(String messengerUser, String hash) throws MalformedURLException, MessengerApiException, MessengerIOException {
final UrlButton urlButton = UrlButton.create("LOGIN",
new URL("https://juick.com/signup?type=messenger&hash=" + hash));
ButtonTemplate template = ButtonTemplate.create("Login to receive notifications",
diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java
index 73b8c3a8..0417afe1 100644
--- a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java
+++ b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java
@@ -61,7 +61,7 @@ public class TelegramBotManager implements ApplicationListener<MessageEvent> {
@Inject
private SubscriptionService subscriptionService;
- public static final String MSG_LINK = "🔗";
+ private static final String MSG_LINK = "🔗";
@PostConstruct
public void init() {
diff --git a/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java b/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java
index 32a88a0c..edda931b 100644
--- a/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java
+++ b/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java
@@ -24,6 +24,7 @@ import org.apache.commons.codec.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
+import javax.annotation.Nonnull;
import javax.servlet.Filter;
/**
@@ -47,6 +48,7 @@ public class ApiInitializer extends AbstractAnnotationConfigDispatcherServletIni
}
@Override
+ @Nonnull
protected String[] getServletMappings() {
return new String[]{"/"};
}
@@ -57,6 +59,7 @@ public class ApiInitializer extends AbstractAnnotationConfigDispatcherServletIni
}
@Override
+ @Nonnull
protected String getServletName() {
return "API dispatcher servlet";
}
diff --git a/juick-api/src/main/java/com/juick/api/controllers/Post.java b/juick-api/src/main/java/com/juick/api/controllers/Post.java
index 92daf2e7..27a0e3c8 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/Post.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/Post.java
@@ -19,6 +19,7 @@ package com.juick.api.controllers;
import com.juick.User;
import com.juick.api.ApiServer;
+import com.juick.api.EmailManager;
import com.juick.server.util.*;
import com.juick.service.MessagesService;
import com.juick.service.SubscriptionService;
@@ -252,7 +253,7 @@ public class Post {
});
String[] inReplyToHeaders = msg.getHeader("In-Reply-To");
if (inReplyToHeaders != null && inReplyToHeaders.length > 0) {
- Scanner inReplyToScanner = new Scanner(inReplyToHeaders[0].trim()).useDelimiter("\\.|@|<");
+ Scanner inReplyToScanner = new Scanner(inReplyToHeaders[0].trim()).useDelimiter(EmailManager.MSGID_PATTERN);
int mid = Integer.parseInt(inReplyToScanner.next());
int rid = Integer.parseInt(inReplyToScanner.next());
logger.info("Message is reply to #{}/{}", mid, rid);