From 516dce5aedf9b45557e6d1eb62ac797987290c1f Mon Sep 17 00:00:00 2001 From: soshial Date: Sun, 25 Apr 2021 10:28:11 +0400 Subject: cleanse NotificatorTelegram before merge --- .../traccar/notificators/NotificatorTelegram.java | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/main/java/org/traccar/notificators/NotificatorTelegram.java') diff --git a/src/main/java/org/traccar/notificators/NotificatorTelegram.java b/src/main/java/org/traccar/notificators/NotificatorTelegram.java index 607eeaf24..bd23684d4 100644 --- a/src/main/java/org/traccar/notificators/NotificatorTelegram.java +++ b/src/main/java/org/traccar/notificators/NotificatorTelegram.java @@ -16,7 +16,6 @@ package org.traccar.notificators; import com.fasterxml.jackson.annotation.JsonProperty; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.traccar.Context; @@ -25,7 +24,6 @@ import org.traccar.model.Event; import org.traccar.model.Position; import org.traccar.notification.NotificationFormatter; -import javax.annotation.Nullable; import javax.ws.rs.client.Entity; import javax.ws.rs.client.InvocationCallback; @@ -42,9 +40,6 @@ public class NotificatorTelegram extends Notificator { private String chatId; @JsonProperty("text") private String text; - @Nullable - @JsonProperty("reply_to_message_id") - private Long replyToMessageId; @JsonProperty("parse_mode") private String parseMode = "html"; } @@ -86,20 +81,24 @@ public class NotificatorTelegram extends Notificator { }); } + private LocationMessage createMessage(Position position) { + LocationMessage locationMessage = new LocationMessage(); + locationMessage.chatId = chatId; + locationMessage.latitude = position.getLatitude(); + locationMessage.longitude = position.getLongitude(); + locationMessage.bearing = (int) Math.ceil(position.getCourse()); + locationMessage.accuracy = position.getAccuracy(); + return locationMessage; + } + @Override public void sendSync(long userId, Event event, Position position) { if (position != null) { - LocationMessage locationMessage = new LocationMessage(); - locationMessage.chatId = chatId; - locationMessage.latitude = position.getLatitude(); - locationMessage.longitude = position.getLongitude(); - locationMessage.bearing = (int) Math.ceil(position.getCourse()); - locationMessage.accuracy = position.getAccuracy(); + LocationMessage locationMessage = createMessage(position); executeRequest(urlSendLocation, locationMessage); } TextMessage message = new TextMessage(); message.chatId = chatId; - // message.replyToMessageId = Long.MIN_VALUE; TODO add message ID from the first request here message.text = NotificationFormatter.formatFullMessage(userId, event, position).getBody(); executeRequest(urlSendText, message); } -- cgit v1.2.3