aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api/src')
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java6
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/Post.java8
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java6
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java6
4 files changed, 12 insertions, 14 deletions
diff --git a/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java b/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java
index 1a79cbec5..e0bbc6985 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java
@@ -27,8 +27,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
@@ -52,8 +52,8 @@ public class MessengerWebhook {
}
@RequestMapping(value = "/fbwbhk", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
- public void processUpdate(HttpServletRequest req) throws IOException {
- String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);
+ public void processUpdate(InputStream body) throws IOException {
+ String data = IOUtils.toString(body, StandardCharsets.UTF_8);
logger.info("got data: {}", data);
}
}
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 7696b7d81..5a32ade07 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
@@ -43,9 +43,9 @@ import javax.inject.Inject;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
-import javax.servlet.http.HttpServletRequest;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -224,10 +224,8 @@ public class Post {
@PostMapping("/mail")
@ResponseStatus(value = HttpStatus.OK)
- public void processMail(HttpServletRequest req) throws Exception {
- String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);
- logger.info("got data: {}", data);
- MimeMessage msg = new MimeMessage(session, IOUtils.toInputStream(data, StandardCharsets.UTF_8));
+ public void processMail(InputStream data) throws Exception {
+ MimeMessage msg = new MimeMessage(session, data);
String from = msg.getFrom().length > 1 ? ((InternetAddress) msg.getSender()).getAddress()
: ((InternetAddress) msg.getFrom()[0]).getAddress();
logger.info("got msg from {}", from);
diff --git a/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java b/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java
index 8034a284d..826226523 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java
@@ -26,8 +26,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
-import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
@@ -38,8 +38,8 @@ public class SkypeEndpoint {
private static final Logger logger = LoggerFactory.getLogger(SkypeEndpoint.class);
@RequestMapping(value = "/skypebotendpoint", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
- public void doPost(HttpServletRequest req) throws IOException {
- String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);
+ public void doPost(InputStream body) throws IOException {
+ String data = IOUtils.toString(body, StandardCharsets.UTF_8);
logger.info("got data: {}", data);
}
}
diff --git a/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java b/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java
index be29ee621..dc10ceba6 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java
@@ -34,8 +34,8 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
@@ -55,8 +55,8 @@ public class TelegramWebhook {
@RequestMapping(value = "/tlgmbtwbhk", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
- public void processUpdate(HttpServletRequest request) throws IOException {
- Update update = BotUtils.parseUpdate(IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8));
+ public void processUpdate(InputStream body) throws IOException {
+ Update update = BotUtils.parseUpdate(IOUtils.toString(body, StandardCharsets.UTF_8));
Message message = update.message();
if (update.message() == null) {
message = update.editedMessage();