Skip to content

Commit

Permalink
Fixed small errors
Browse files Browse the repository at this point in the history
  • Loading branch information
msnijder30 committed Nov 25, 2016
1 parent 6d68b23 commit 67b9b10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/nl/marksnijder/jkik/KikBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ public final void onMessageReceived(String data) {

case LINK:
String url = obj.get("url").getAsString();
String text = obj.get("text").getAsString();
String text = obj.has("text") && !obj.get("text").isJsonNull() ? obj.get("text").getAsString() : null;

JsonObject dataAttr = obj.has("kikJsData") && !obj.get("kikJsData").isJsonNull() && obj.get("kikJsData").isJsonObject() ? obj.get("attribution").getAsJsonObject() : null;

JsonObject objAttr = (JsonObject) obj.get("attribution");
MessageAttribute at = new MessageAttribute(objAttr.get("iconUrl").getAsString(), objAttr.get("style").getAsString(), objAttr.get("name").getAsString());

LinkMessage linkMessage = new LinkMessage(chat, timestamp, mention, readReceiptRequested, id, at, url, readReceiptRequested, text);
LinkMessage linkMessage = new LinkMessage(chat, timestamp, mention, readReceiptRequested, id, at, url, readReceiptRequested, dataAttr, text);
onLinkReceived(linkMessage);
break;

Expand Down
6 changes: 5 additions & 1 deletion src/nl/marksnijder/jkik/message/LinkMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ public class LinkMessage extends Sendable {

@Getter
private String text;

@Getter
private JsonObject kikJsData;

/**
* @deprecated Please use the other constructors as they have the arguments you need exactly. This constructor is mostly for internal use.
*/
@Deprecated
public LinkMessage(Chat chat, long timestamp, String mention, boolean readReceiptRequested, String id, MessageAttribute attribute, String url, boolean noForward, String text) {
public LinkMessage(Chat chat, long timestamp, String mention, boolean readReceiptRequested, String id, MessageAttribute attribute, String url, boolean noForward, JsonObject kikJsData, String text) {
super(chat, timestamp, mention, readReceiptRequested, MessageType.LINK, id);
this.attribute = attribute;
this.url = url;
this.noForward = noForward;
this.kikJsData = kikJsData;
this.text = text;
}

Expand Down

0 comments on commit 67b9b10

Please sign in to comment.