aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorsoshial <soshial@gmail.com>2021-04-25 10:28:11 +0400
committersoshial <soshial@gmail.com>2021-04-25 10:28:11 +0400
commit516dce5aedf9b45557e6d1eb62ac797987290c1f (patch)
tree0b0458cd4533f6ec7df56871f50703a2a1136a7d /src/main/java/org
parent383d61a7ebb64ea142fce47b3c6c627e5cb90be4 (diff)
downloadtraccar-server-516dce5aedf9b45557e6d1eb62ac797987290c1f.tar.gz
traccar-server-516dce5aedf9b45557e6d1eb62ac797987290c1f.tar.bz2
traccar-server-516dce5aedf9b45557e6d1eb62ac797987290c1f.zip
cleanse NotificatorTelegram before merge
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTelegram.java23
1 files changed, 11 insertions, 12 deletions
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);
}