From f89f0ef542f9dd9970f0ce638f4989adf62395e8 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 15 May 2021 12:52:31 -0400 Subject: [PATCH] add a simple user constructor --- .../repositories/responses/User.java | 55 +++++++++++++-- .../responses/search/SearchItem.java | 8 +-- .../instagrabber/utils/ResponseBodyUtils.java | 6 +- .../viewmodels/CommentsViewerViewModel.java | 6 +- .../webservices/GraphQLService.java | 35 +--------- .../webservices/StoriesService.java | 68 +------------------ 6 files changed, 57 insertions(+), 121 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/User.java b/app/src/main/java/awais/instagrabber/repositories/responses/User.java index b2f2a0b2..716735e3 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/User.java +++ b/app/src/main/java/awais/instagrabber/repositories/responses/User.java @@ -28,11 +28,10 @@ public class User implements Serializable { private final long usertagsCount; private final String publicEmail; private final HdProfilePicUrlInfo hdProfilePicUrlInfo; - private final String profileContext; - private final List profileContextLinksWithUserIds; - private final String socialContext; - // if a DM member is a Facebook user, this is present - private final String interopMessagingUserFbid; + private final String profileContext; // "also followed by" your friends + private final List profileContextLinksWithUserIds; // ^ + private final String socialContext; // AYML + private final String interopMessagingUserFbid; // in DMs only: Facebook user ID public User(final long pk, final String username, @@ -90,6 +89,52 @@ public class User implements Serializable { this.interopMessagingUserFbid = interopMessagingUserFbid; } + public User(final long pk, + final String username, + final String fullName, + final boolean isPrivate, + final String profilePicUrl, + final boolean isVerified) { + this.pk = pk; + this.username = username; + this.fullName = fullName; + this.isPrivate = isPrivate; + this.profilePicUrl = profilePicUrl; + this.profilePicId = null; + this.friendshipStatus = new FriendshipStatus( + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ); + this.isVerified = isVerified; + this.hasAnonymousProfilePicture = false; + this.isUnpublished = false; + this.isFavorite = false; + this.isDirectappInstalled = false; + this.reelAutoArchive = null; + this.allowedCommenterType = null; + this.mediaCount = 0; + this.followerCount = 0; + this.followingCount = 0; + this.followingTagCount = 0; + this.biography = null; + this.externalUrl = null; + this.usertagsCount = 0; + this.publicEmail = null; + this.hdProfilePicUrlInfo = null; + this.profileContext = null; + this.profileContextLinksWithUserIds = null; + this.socialContext = null; + this.interopMessagingUserFbid = null; + } + public long getPk() { return pk; } diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchItem.java b/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchItem.java index f99c7dfd..9f56b765 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchItem.java +++ b/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchItem.java @@ -191,9 +191,7 @@ public class SearchItem { recentSearch.getName(), false, recentSearch.getPicUrl(), - null, null, false, false, false, false, false, - null, null, 0, 0, 0, 0, null, null, - 0, null, null, null, null, null, null + false ); } @@ -205,9 +203,7 @@ public class SearchItem { favorite.getDisplayName(), false, favorite.getPicUrl(), - null, null, false, false, false, false, false, - null, null, 0, 0, 0, 0, null, null, - 0, null, null, null, null, null, null + false ); } diff --git a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java index b3968fdd..f205b04f 100644 --- a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java @@ -767,11 +767,7 @@ public final class ResponseBodyUtils { owner.optString("full_name"), false, owner.optString("profile_pic_url"), - null, - friendshipStatus, - owner.optBoolean("is_verified"), - false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null, - null, null, null, null); + owner.optBoolean("is_verified")); } final String id = feedItem.getString(Constants.EXTRAS_ID); VideoVersion videoVersion = null; diff --git a/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java b/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java index 109b6fea..ab42e84d 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java +++ b/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java @@ -238,11 +238,7 @@ public class CommentsViewerViewModel extends ViewModel { null, false, owner.getString("profile_pic_url"), - null, - new FriendshipStatus(false, false, false, false, false, false, false, false, false, false), - owner.optBoolean("is_verified"), - false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null, null, null, - null, null); + owner.optBoolean("is_verified")); final JSONObject likedBy = commentJsonObject.optJSONObject("edge_liked_by"); final String commentId = commentJsonObject.getString("id"); final JSONObject childCommentsJsonObject = commentJsonObject.optJSONObject("edge_threaded_comments"); diff --git a/app/src/main/java/awais/instagrabber/webservices/GraphQLService.java b/app/src/main/java/awais/instagrabber/webservices/GraphQLService.java index eef7af9a..20cf6918 100644 --- a/app/src/main/java/awais/instagrabber/webservices/GraphQLService.java +++ b/app/src/main/java/awais/instagrabber/webservices/GraphQLService.java @@ -34,7 +34,6 @@ import retrofit2.Response; public class GraphQLService extends BaseService { private static final String TAG = "GraphQLService"; - // private static final boolean loadFromMock = false; private final GraphQLRepository repository; @@ -230,39 +229,7 @@ public class GraphQLService extends BaseService { userObject.optString("full_name"), userObject.optBoolean("is_private"), userObject.getString("profile_pic_url"), - null, - new FriendshipStatus( - false, - false, - false, - false, - false, - false, - false, - false, - false, - false - ), - userObject.optBoolean("is_verified"), - false, - false, - false, - false, - null, - null, - 0, - 0, - 0, - 0, - null, - null, - 0, - null, - null, - null, - null, - null, - null + userObject.optBoolean("is_verified") )); // userModels.add(new ProfileModel(userObject.optBoolean("is_private"), // false, diff --git a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java index 169f630a..96e9bc7d 100644 --- a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java +++ b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java @@ -143,39 +143,7 @@ public class StoriesService extends BaseService { userJson.optString("full_name"), userJson.optBoolean("is_private"), userJson.getString("profile_pic_url"), - null, - new FriendshipStatus( - false, - false, - false, - false, - false, - false, - false, - false, - false, - false - ), - userJson.optBoolean("is_verified"), - false, - false, - false, - false, - null, - null, - 0, - 0, - 0, - 0, - null, - null, - 0, - null, - null, - null, - null, - null, - null + userJson.optBoolean("is_verified") ); final long timestamp = node.getLong("latest_reel_media"); final boolean fullyRead = !node.isNull("seen") && node.getLong("seen") == timestamp; @@ -210,39 +178,7 @@ public class StoriesService extends BaseService { userJson.optString("full_name"), userJson.optBoolean("is_private"), userJson.getString("profile_pic_url"), - null, - new FriendshipStatus( - false, - false, - false, - false, - false, - false, - false, - false, - false, - false - ), - userJson.optBoolean("is_verified"), - false, - false, - false, - false, - null, - null, - 0, - 0, - 0, - 0, - null, - null, - 0, - null, - null, - null, - null, - null, - null + userJson.optBoolean("is_verified") ); feedStoryModels.add(new FeedStoryModel( node.getString("id"),