Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better fix for TFJ-619, support current_user_retweet field in Status …

…object
  • Loading branch information...
commit d82879c3bccea2f7218c3f54dfb74bd4b47711ab 1 parent 65287ac
@goncalossilva authored
View
11 twitter4j-appengine/src/main/java/twitter4j/internal/json/LazyStatus.java
@@ -230,6 +230,17 @@ public long getRetweetCount() {
public boolean isRetweetedByMe() {
return getTarget().isRetweetedByMe();
}
+
+ /**
+ * Returns the authenticating user's retweet of this tweet, or null when the tweet was created
+ * before this feature was enabled. Note that the available information is restricted to its id.
+ *
+ * @return the authenticating user's retweet of this tweet
+ * @since Twitter4J 2.2.6
+ */
+ public Status getMyRetweet() {
+ return getTarget().getMyRetweet();
+ }
/**
View
9 twitter4j-core/src/main/java/twitter4j/Status.java
@@ -154,6 +154,15 @@
* @since Twitter4J 2.1.4
*/
boolean isRetweetedByMe();
+
+ /**
+ * Returns the authenticating user's retweet of this tweet, or null when the tweet was created
+ * before this feature was enabled. Note that the available information is restricted to its id.
+ *
+ * @return the authenticating user's retweet of this tweet
+ * @since Twitter4J 2.2.6
+ */
+ Status getMyRetweet();
/**
* Returns the annotations, or null if no annotations are associated with this status.
View
2  twitter4j-core/src/main/java/twitter4j/TwitterImpl.java
@@ -421,7 +421,7 @@ public IDs getRetweetedByIDs(long statusId, Paging paging) throws TwitterExcepti
* {@inheritDoc}
*/
public Status showStatus(long id) throws TwitterException {
- return factory.createStatus(get(conf.getRestBaseURL() + "statuses/show/" + id + ".json?include_entities="
+ return factory.createStatus(get(conf.getRestBaseURL() + "statuses/show/" + id + ".json?include_my_retweet=1&include_entities="
+ conf.isIncludeEntitiesEnabled()));
}
View
13 twitter4j-core/src/main/java/twitter4j/internal/json/StatusJSONImpl.java
@@ -53,7 +53,6 @@
private GeoLocation geoLocation = null;
private Place place = null;
private long retweetCount;
- private boolean wasRetweetedByMe;
private String[] contributors = null;
private long[] contributorsIDs;
@@ -187,7 +186,6 @@ private void init(JSONObject json) throws TwitterException {
if (!json.isNull("current_user_retweet")) {
try {
myRetweetedStatus = new StatusJSONImpl(json.getJSONObject("current_user_retweet"));
- wasRetweetedByMe = true;
} catch (JSONException ignore) {
ignore.printStackTrace();
logger.warn("failed to parse current_user_retweet:" + json);
@@ -346,7 +344,14 @@ public long getRetweetCount() {
* {@inheritDoc}
*/
public boolean isRetweetedByMe() {
- return wasRetweetedByMe;
+ return myRetweetedStatus != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Status getMyRetweet() {
+ return myRetweetedStatus;
}
/**
@@ -436,7 +441,7 @@ public String toString() {
", geoLocation=" + geoLocation +
", place=" + place +
", retweetCount=" + retweetCount +
- ", wasRetweetedByMe=" + wasRetweetedByMe +
+ ", myRetweetedStatus=" + myRetweetedStatus +
", contributors=" + (contributorsIDs == null ? null : Arrays.asList(contributorsIDs)) +
", annotations=" + annotations +
", retweetedStatus=" + retweetedStatus +

0 comments on commit d82879c

Please sign in to comment.
Something went wrong with that request. Please try again.