aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-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) {