diff options
Diffstat (limited to 'juick-api/src/main/java/com/juick/api')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/EmailManager.java | 3 | ||||
-rw-r--r-- | juick-api/src/main/java/com/juick/api/controllers/Post.java | 11 |
2 files changed, 11 insertions, 3 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 df15d9de..a01eac78 100644 --- a/juick-api/src/main/java/com/juick/api/EmailManager.java +++ b/juick-api/src/main/java/com/juick/api/EmailManager.java @@ -2,7 +2,6 @@ package com.juick.api; import com.juick.Message; import com.juick.server.component.MessageEvent; -import com.juick.server.util.HttpBadRequestException; import com.juick.service.EmailService; import com.juick.service.MessagesService; import com.juick.service.SubscriptionService; @@ -15,12 +14,10 @@ import org.springframework.stereotype.Component; import javax.inject.Inject; import javax.mail.MessagingException; -import javax.mail.NoSuchProviderException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; - import java.util.Properties; import static com.juick.formatters.PlainTextFormatter.formatPost; 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 33d83d2c..032b549b 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 @@ -52,6 +52,7 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.Properties; +import java.util.Scanner; import java.util.UUID; /** @@ -210,6 +211,7 @@ public class Post { String from = msg.getFrom().length > 1 ? ((InternetAddress) msg.getSender()).getAddress() : ((InternetAddress) msg.getFrom()[0]).getAddress(); logger.info("got msg from {}", from); + User visitor = userService.getUserByEmail(from); if (!visitor.isAnonymous()) { MimeMessageParser parser = new MimeMessageParser(msg); @@ -248,6 +250,15 @@ public class Post { logger.info("attachment error: {}", e); } }); + String[] inReplyToHeaders = msg.getHeader("In-Reply-To"); + if (inReplyToHeaders != null && inReplyToHeaders.length > 0) { + Scanner inReplyToScanner = new Scanner(inReplyToHeaders[0].trim()).useDelimiter("\\.|@|<"); + int mid = Integer.parseInt(inReplyToScanner.next()); + int rid = Integer.parseInt(inReplyToScanner.next()); + logger.info("Message is reply to #%d/%d", mid, rid); + body[0] = rid > 0 ? String.format("#%d/%d %s", mid, rid, body[0]) + : String.format("#%d %s", mid, body[0]); + } rocks.xmpp.core.stanza.model.Message xmsg = new rocks.xmpp.core.stanza.model.Message(); xmsg.setType(rocks.xmpp.core.stanza.model.Message.Type.CHAT); xmsg.setFrom(Jid.of(String.valueOf(visitor.getUid()), "uid.juick.com", "mail")); |