allow attachment removal

This commit is contained in:
mrbesen 2020-06-14 18:04:50 +02:00
parent 9f7829b28a
commit 57db456a80
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 9 additions and 4 deletions

View File

@ -107,15 +107,20 @@ public class MessageBuilder {
}
public MessageBuilder setAttachment(Attachment type, String cont) {
if(cont == null) {
if(type != Attachment.none) throw new IllegalArgumentException("cont == null requires type == none");
attachmenttype = type;
attachment = null;
return this;
}
if(attachmenttype != Attachment.none) {
throw new IllegalArgumentException("You can only attach one thing!");
}
if(cont == null) {
throw new IllegalArgumentException("attachment empty!");
}
attachmenttype = type;
try {
attachment = URLEncoder.encode(cont, "UTF-8");
attachment = URLEncoder.encode(cont, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}