mirror of
https://github.com/traccar/traccar.git
synced 2026-06-12 19:04:56 -04:00
Send Telegram location per user (fix #5174)
This commit is contained in:
@@ -1409,7 +1409,7 @@ public final class Keys {
|
||||
*/
|
||||
public static final ConfigKey<Boolean> NOTIFICATOR_TELEGRAM_SEND_LOCATION = new BooleanConfigKey(
|
||||
"notificator.telegram.sendLocation",
|
||||
List.of(KeyType.CONFIG));
|
||||
List.of(KeyType.CONFIG, KeyType.USER));
|
||||
|
||||
/**
|
||||
* Telegram notification proxy URL.
|
||||
|
||||
@@ -116,7 +116,10 @@ public class NotificatorTelegram extends Notificator {
|
||||
}
|
||||
message.text = shortMessage.digest();
|
||||
client.target(urlSendText).request().post(Entity.json(message)).close();
|
||||
if (sendLocation && position != null) {
|
||||
boolean sendUserLocation = user.hasAttribute(Keys.NOTIFICATOR_TELEGRAM_SEND_LOCATION.getKey())
|
||||
? user.getBoolean(Keys.NOTIFICATOR_TELEGRAM_SEND_LOCATION.getKey())
|
||||
: sendLocation;
|
||||
if (sendUserLocation && position != null) {
|
||||
client.target(urlSendLocation).request().post(
|
||||
Entity.json(createLocationMessage(message.chatId, position))).close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user