Added max character validation

This commit is contained in:
Sven Kubiak 2020-03-05 14:35:32 +01:00
parent 684a166f0b
commit e57c945c3a

View File

@ -289,7 +289,7 @@ public class Message {
Objects.requireNonNull(this.token, "Token is required for a message"); Objects.requireNonNull(this.token, "Token is required for a message");
Objects.requireNonNull(this.user, "User is required for a message"); Objects.requireNonNull(this.user, "User is required for a message");
Objects.requireNonNull(this.message, "Message is required for a message"); Objects.requireNonNull(this.message, "Message is required for a message");
if (Priority.EMERGENCY.equals(this.priority)) { if (Priority.EMERGENCY.equals(this.priority)) {
if (this.retry == 0) { if (this.retry == 0) {
this.retry = 60; this.retry = 60;
@ -300,6 +300,22 @@ public class Message {
} }
} }
if (this.message.length() > 1024) {
this.message.substring(0, 1023);
}
if (this.title != null && this.title.length() > 250) {
this.title.substring(0, 249);
}
if (this.url != null && this.url.length() > 512) {
this.url.substring(0, 511);
}
if (this.urlTitle != null && this.urlTitle.length() > 100) {
this.urlTitle.substring(0, 99);
}
NavigableMap<String, String> body = new TreeMap<>(); NavigableMap<String, String> body = new TreeMap<>();
body.put(Param.TOKEN.toString(), this.token); body.put(Param.TOKEN.toString(), this.token);
body.put(Param.USER.toString(), this.user); body.put(Param.USER.toString(), this.user);