aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api/src/main/java')
-rw-r--r--juick-api/src/main/java/com/juick/api/TGBot.java9
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/Post.java7
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java8
3 files changed, 14 insertions, 10 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TGBot.java b/juick-api/src/main/java/com/juick/api/TGBot.java
index e0ab3e1e..d532b02c 100644
--- a/juick-api/src/main/java/com/juick/api/TGBot.java
+++ b/juick-api/src/main/java/com/juick/api/TGBot.java
@@ -79,7 +79,10 @@ public class TGBot implements AutoCloseable {
public void onTextMessage(WebSocket websocket, String text) throws Exception {
super.onTextMessage(websocket, text);
com.juick.Message jmsg = ms.readValue(text, com.juick.Message.class);
- logger.info("got jmsg: " + ms.writeValueAsString(jmsg));
+
+ if (logger.isInfoEnabled()) // prevent writeValueAsString execution if logger disabled
+ logger.info("got jmsg: {}", ms.writeValueAsString(jmsg));
+
String msgUrl = formatUrl(jmsg);
if (jmsg.getRid() == 0) {
String msg = formatPost(jmsg);
@@ -118,7 +121,7 @@ public class TGBot implements AutoCloseable {
bot.execute(telegramMessage, new Callback<SendMessage, SendResponse>() {
@Override
public void onResponse(SendMessage request, SendResponse response) {
- logger.info("got response: " + response.message().toString());
+ logger.info("got response: {}", response.message());
}
@Override
@@ -140,7 +143,7 @@ public class TGBot implements AutoCloseable {
})), new Callback<SendMessage, SendResponse>() {
@Override
public void onResponse(SendMessage request, SendResponse response) {
- logger.info("got response: " + response.message().toString());
+ logger.info("got response: {}", response.message());
}
@Override
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 18f417d8..0fbf87e8 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
@@ -99,7 +99,7 @@ public class Post {
}
String attachmentFName = HttpUtils.receiveMultiPartFile(attach, env.getProperty("upload_tmp_dir",
- "/var/www/juick.com/i/tmp/"));
+ "/var/www/juick.com/i/tmp/"));
if (StringUtils.isBlank(attachmentFName) && img != null && img.length() > 10) {
try {
@@ -142,7 +142,7 @@ public class Post {
OobX xoob = new OobX(new URI(attachmentURL));
xmsg.addExtension(xoob);
} catch (URISyntaxException e) {
- logger.error("invalid uri: " + attachmentURL, e);
+ logger.error("invalid uri: {}, exception {}", attachmentURL, e);
}
}
@@ -173,6 +173,7 @@ public class Post {
}
return jmsg;
}
+
@RequestMapping(value = "/comment", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public com.juick.Message doPostComment(
Principal principal,
@@ -263,7 +264,7 @@ public class Post {
try {
xmsg.addExtension(new OobX(new URI(attachmentURL)));
} catch (URISyntaxException e) {
- logger.error("invalid uri: " + attachmentURL, e);
+ logger.error("invalid uri: {}, exception {}", attachmentURL, e);
}
}
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 8b491167..60856ec6 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
@@ -38,13 +38,13 @@ public class TelegramWebhook {
if (update.message() == null) {
message = update.editedMessage();
if (message == null) {
- logger.error("error parsing telegram update: " + update.toString());
+ logger.error("error parsing telegram update: {}", update);
return;
}
}
- logger.info(String.format("got telegram msg %s", message.toString()));
+ logger.info("got telegram msg {}", message);
User user_from = usersService.getUserByUID(telegramService.getUser(message.chat().id())).orElse(new User());
- logger.info(String.format("Found juick user %d", user_from.getUid()));
+ logger.info("Found juick user {}", user_from.getUid());
List<Long> chats = telegramService.getChats();
String username = message.from().username();
@@ -53,7 +53,7 @@ public class TelegramWebhook {
}
if (!chats.contains(message.chat().id())) {
telegramService.addChat(message.chat().id());
- logger.info("added chat with " + username);
+ logger.info("added chat with {}", username);
telegramService.createTelegramUser(message.from().id(), username);
tgBot.telegramSignupNotify(message.from().id().longValue(), usersService.getSignUpHashByTelegramID(message.from().id().longValue(), username));
} else {