aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-20 10:40:51 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-20 10:40:51 -0700
commit6b93bac13dc044c3155794226a670257d841554e (patch)
tree12d3b0abdcc95f32c7092f43b56fc103a003f126
parent24be0a7aa9ee04da30f2da81c0ba5d21e2353f5d (diff)
downloadtraccar-server-6b93bac13dc044c3155794226a670257d841554e.tar.gz
traccar-server-6b93bac13dc044c3155794226a670257d841554e.tar.bz2
traccar-server-6b93bac13dc044c3155794226a670257d841554e.zip
Fix review comments
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTelegram.java26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorTelegram.java b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
index 34e9f9c9d..89c15ba7c 100644
--- a/src/main/java/org/traccar/notificators/NotificatorTelegram.java
+++ b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
@@ -1,6 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
- * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2019 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +14,7 @@
* limitations under the License.
*/
package org.traccar.notificators;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,35 +30,33 @@ public class NotificatorTelegram extends Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorTelegram.class);
- private String urlString = "https://api.telegram.org/bot%s/sendMessage";
- private String apikey;
- private String chatid;
+ private String url;
+ private String chatId;
public static class Message {
@JsonProperty("chat_id")
- private String chatid;
+ private String chatId;
@JsonProperty("text")
private String text;
@JsonProperty("parse_mode")
- private String parsemode;
-
+ private String parseMode = "html";
}
public NotificatorTelegram() {
- apikey = Context.getConfig().getString("notificator.Telegram.apikey");
- chatid = Context.getConfig().getString("notificator.Telegram.chatid");
+ url = String.format(
+ "https://api.telegram.org/bot%s/sendMessage",
+ Context.getConfig().getString("notificator.telegram.key"));
+ chatId = Context.getConfig().getString("notificator.Telegram.chatid");
}
@Override
public void sendSync(long userId, Event event, Position position) {
Message message = new Message();
- message.chatid = chatid;
- message.parsemode = "html";
+ message.chatId = chatId;
message.text = NotificationFormatter.formatShortMessage(userId, event, position);
- urlString = String.format(urlString, apikey);
- Context.getClient().target(urlString).request()
+ Context.getClient().target(url).request()
.async().post(Entity.json(message), new InvocationCallback<Object>() {
@Override
public void completed(Object o) {