Fix #841
This commit is contained in:
parent
415d31eaec
commit
451bdce90b
@ -102,7 +102,7 @@ public class SendPoll extends BotApiMethod<Message> {
|
||||
private String explanationParseMode; ///< Optional. Mode for parsing entities in the explanation. See formatting options for more details.
|
||||
@JsonProperty(EXPLANATION_ENTITIES_FIELD)
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the poll explanation, which can be specified instead of parse_mode
|
||||
private List<MessageEntity> explanationEntities; ///< Optional. List of special entities that appear in the poll explanation, which can be specified instead of parse_mode
|
||||
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
@ -158,7 +158,7 @@ public class SendPoll extends BotApiMethod<Message> {
|
||||
if (options.parallelStream().anyMatch(x -> x.isEmpty() || x.length() > 100)) {
|
||||
throw new TelegramApiValidationException("Options parameter values must be between 1 and 100 chars length", this);
|
||||
}
|
||||
if (explanationParseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
if (explanationParseMode != null && (explanationEntities != null && !explanationEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
|
@ -49,6 +49,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
public static final String DISABLECONTENTTYPEDETECTION_FIELD = "disable_content_type_detection";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
|
||||
@ -71,6 +72,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
private Boolean disableContentTypeDetection; ///< Optional Disables automatic server-side content type detection for files uploaded using multipart/form-data
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
|
@ -46,7 +46,7 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
|
||||
private static final String PROXIMITYALERTRADIUS_FIELD = "proximity_alert_radius";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
@ -85,8 +85,8 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
* For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Must be between 1 and 100000 if specified.
|
||||
*/
|
||||
@JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
|
||||
private Integer approachingNotificationDistance;
|
||||
@JsonProperty(PROXIMITYALERTRADIUS_FIELD)
|
||||
private Integer proximityAlertRadius;
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
@ -131,10 +131,10 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (heading != null && (heading < 1 || heading > 360)) {
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 1 and 360", this);
|
||||
}
|
||||
if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
|
||||
if (proximityAlertRadius != null && (proximityAlertRadius < 1 || proximityAlertRadius > 100000)) {
|
||||
throw new TelegramApiValidationException("Proximity alert radius parameter must be between 1 and 100000", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
|
@ -46,7 +46,7 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
|
||||
private static final String PROXIMITYALERTRADIUS_FIELD = "proximity_alert_radius";
|
||||
|
||||
/**
|
||||
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
|
||||
@ -90,8 +90,8 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
* For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Must be between 1 and 100000 if specified.
|
||||
*/
|
||||
@JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
|
||||
private Integer approachingNotificationDistance;
|
||||
@JsonProperty(PROXIMITYALERTRADIUS_FIELD)
|
||||
private Integer proximityAlertRadius;
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -151,10 +151,10 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (heading != null && (heading < 1 || heading > 360)) {
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 1 and 360", this);
|
||||
}
|
||||
if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
|
||||
if (proximityAlertRadius != null && (proximityAlertRadius < 1 || proximityAlertRadius > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 1 and 100000", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
|
@ -28,7 +28,7 @@ public class Location implements BotApiObject {
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String LIVEPERIOD_FIELD = "live_period";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String PROXMITYALERTDISTANCE_FIELD = "proximity_alert_distance";
|
||||
private static final String PROXMITYALERTRADIUS_FIELD = "proximity_alert_radius";
|
||||
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
@NonNull
|
||||
@ -41,7 +41,6 @@ public class Location implements BotApiObject {
|
||||
* The radius of uncertainty for the location, measured in meters; 0-1500
|
||||
*/
|
||||
@JsonProperty(HORIZONTALACCURACY_FIELD)
|
||||
@NonNull
|
||||
private Double horizontalAccuracy;
|
||||
/**
|
||||
* Optional.
|
||||
@ -49,21 +48,18 @@ public class Location implements BotApiObject {
|
||||
* For active live locations only.
|
||||
*/
|
||||
@JsonProperty(LIVEPERIOD_FIELD)
|
||||
@NonNull
|
||||
private Integer livePeriod;
|
||||
/**
|
||||
* Optional.
|
||||
* The direction in which user is moving, in degrees; 1-360. For active live locations only.
|
||||
*/
|
||||
@JsonProperty(HEADING_FIELD)
|
||||
@NonNull
|
||||
private Integer heading;
|
||||
/**
|
||||
* Optional.
|
||||
* A maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* For sent live locations only.
|
||||
*/
|
||||
@JsonProperty(PROXMITYALERTDISTANCE_FIELD)
|
||||
@NonNull
|
||||
private Integer proximityAlertDistance;
|
||||
@JsonProperty(PROXMITYALERTRADIUS_FIELD)
|
||||
private Integer proximityAlertRadius;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class InputLocationMessageContent implements InputMessageContent {
|
||||
private static final String LIVEPERIOD_FIELD = "live_period";
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
|
||||
private static final String PROXIMITYALERTRADIUS_FIELD = "proximity_alert_radius";
|
||||
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
@NonNull
|
||||
@ -64,8 +64,8 @@ public class InputLocationMessageContent implements InputMessageContent {
|
||||
* For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Must be between 1 and 100000 if specified.
|
||||
*/
|
||||
@JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
|
||||
private Integer approachingNotificationDistance;
|
||||
@JsonProperty(PROXIMITYALERTRADIUS_FIELD)
|
||||
private Integer proximityAlertRadius;
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
@ -82,10 +82,10 @@ public class InputLocationMessageContent implements InputMessageContent {
|
||||
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (heading != null && (heading < 1 || heading > 360)) {
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 1 and 360", this);
|
||||
}
|
||||
if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
|
||||
if (proximityAlertRadius != null && (proximityAlertRadius < 1 || proximityAlertRadius > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 1 and 100000", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class InlineQueryResultLocation implements InlineQueryResult {
|
||||
private static final String LIVEPERIOD_FIELD = "live_period";
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
|
||||
private static final String PROXIMITYALERTRADIUS_FIELD = "proximity_alert_radius";
|
||||
|
||||
@JsonProperty(TYPE_FIELD)
|
||||
private final String type = "location"; ///< Type of the result, must be "location"
|
||||
@ -95,8 +95,8 @@ public class InlineQueryResultLocation implements InlineQueryResult {
|
||||
* For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Must be between 1 and 100000 if specified.
|
||||
*/
|
||||
@JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
|
||||
private Integer approachingNotificationDistance;
|
||||
@JsonProperty(PROXIMITYALERTRADIUS_FIELD)
|
||||
private Integer proximityAlertRadius;
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
@ -119,10 +119,10 @@ public class InlineQueryResultLocation implements InlineQueryResult {
|
||||
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (heading != null && (heading < 1 || heading > 360)) {
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 1 and 360", this);
|
||||
}
|
||||
if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
|
||||
if (proximityAlertRadius != null && (proximityAlertRadius < 1 || proximityAlertRadius > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 1 and 100000", this);
|
||||
}
|
||||
if (inputMessageContent != null) {
|
||||
inputMessageContent.validate();
|
||||
|
@ -36,13 +36,13 @@ public class TestSerialization {
|
||||
.livePeriod(100)
|
||||
.allowSendingWithoutReply(true)
|
||||
.heading(125)
|
||||
.approachingNotificationDistance(100)
|
||||
.proximityAlertRadius(100)
|
||||
.build();
|
||||
|
||||
String json = mapper.writeValueAsString(location);
|
||||
|
||||
assertNotNull(json);
|
||||
assertEquals("{\"chat_id\":\"12345\",\"latitude\":20.758069,\"longitude\":-0.005702,\"disable_notification\":true,\"reply_to_message_id\":1,\"live_period\":100,\"allow_sending_without_reply\":true,\"horizontal_accuracy\":65.0,\"heading\":125,\"approaching_notification_distance\":100,\"method\":\"sendlocation\"}",
|
||||
assertEquals("{\"chat_id\":\"12345\",\"latitude\":20.758069,\"longitude\":-0.005702,\"disable_notification\":true,\"reply_to_message_id\":1,\"live_period\":100,\"allow_sending_without_reply\":true,\"horizontal_accuracy\":65.0,\"heading\":125,\"proximity_alert_radius\":100,\"method\":\"sendlocation\"}",
|
||||
json);
|
||||
}
|
||||
|
||||
|
@ -180,6 +180,9 @@ public abstract class DefaultAbsSender extends AbsSender {
|
||||
if (sendDocument.getAllowSendingWithoutReply() != null) {
|
||||
builder.addTextBody(SendDocument.ALLOWSENDINGWITHOUTREPLY_FIELD, sendDocument.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||
}
|
||||
if (sendDocument.getDisableContentTypeDetection() != null) {
|
||||
builder.addTextBody(SendDocument.DISABLECONTENTTYPEDETECTION_FIELD, sendDocument.getDisableContentTypeDetection().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||
}
|
||||
if (sendDocument.getCaptionEntities() != null) {
|
||||
builder.addTextBody(SendDocument.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendDocument.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user