revert changes in Message and remove useless if clause in AbsSender

This commit is contained in:
Marcel Caspar 2016-03-21 15:43:24 +01:00
parent ac18b952b9
commit 6ad4491136
2 changed files with 8 additions and 11 deletions

View File

@ -138,9 +138,6 @@ public class Message implements IBotApiObject {
if (jsonObject.has(VIDEO_FIELD)) {
this.video = new Video(jsonObject.getJSONObject(VIDEO_FIELD));
}
if(jsonObject.has(AUDIO_FIELD)){
this.audio = new Audio(jsonObject.getJSONObject(AUDIO_FIELD));
}
if (jsonObject.has(CONTACT_FIELD)) {
this.contact = new Contact(jsonObject.getJSONObject(CONTACT_FIELD));
}

View File

@ -520,16 +520,16 @@ public abstract class AbsSender {
JSONObject jsonObject = new JSONObject(responseContent);
//if we got an ok, then we can expect a "reseult" section. and out of this can a new Message object be built
if(jsonObject.has("ok") && jsonObject.getBoolean("ok")){
return new Message(jsonObject.getJSONObject("result"));
/* if we got not an "ok" with false, we have a response like that
*
* {"description":"[Error]: Bad Request: chat not found","error_code":400,"ok":false}
*/
if(!jsonObject.getBoolean("ok")){
throw new TelegramApiException("Error at sendAudio", jsonObject.getString("description"));
}
//and if not, there should be a field in our jsonObject that represents a boolean "false" with a key of "ok"
//{"description":"[Error]: Bad Request: chat not found","error_code":400,"ok":false}
// for example. and can throw an exception, cause there was an error...
throw new TelegramApiException("Error at sendAudio", jsonObject.getString("description"));
// and if not, we can expect a "result" section. and out of this can a new Message object be built
return new Message(jsonObject.getJSONObject("result"));
}
/**