mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Minor change to distinguish moderators/admins
This commit is contained in:
parent
4741198c78
commit
9ecbaba3d4
@ -292,6 +292,9 @@ public class ParseComment {
|
||||
JSONObject postObj = jsonObject.getJSONObject("post");
|
||||
JSONObject communityObj = jsonObject.getJSONObject("community");
|
||||
JSONObject countsObj = jsonObject.getJSONObject("counts");
|
||||
boolean isModerator = jsonObject.optBoolean("creator_is_moderator");
|
||||
boolean isAdmin = jsonObject.optBoolean("creator_is_admin");
|
||||
|
||||
|
||||
int id = commentObj.getInt("id");
|
||||
int postID = postObj.getInt("id");
|
||||
@ -342,7 +345,7 @@ public class ParseComment {
|
||||
}
|
||||
}
|
||||
boolean isSubmitter = creatorObj.getInt("id") == postObj.getInt("creator_id");
|
||||
String distinguished = commentObj.getString("distinguished");
|
||||
String distinguished = isModerator ? "moderator" : (isAdmin ? "admin" : "");
|
||||
String permalink = commentObj.getString("ap_id");
|
||||
String[] path = commentObj.getString("path").split(Pattern.quote("."));
|
||||
|
||||
|
@ -142,6 +142,8 @@ public class ParsePost {
|
||||
JSONObject creator = data.getJSONObject("creator");
|
||||
JSONObject community = data.getJSONObject("community");
|
||||
JSONObject counts = data.getJSONObject("counts");
|
||||
boolean isModerator = data.getBoolean("creator_is_moderator");
|
||||
boolean isAdmin = creator.optBoolean("admin") || data.optBoolean("creator_is_admin");
|
||||
|
||||
int id = post.getInt("id");
|
||||
String fullName = post.getString("name");
|
||||
@ -182,7 +184,7 @@ public class ParsePost {
|
||||
boolean locked = post.getBoolean("locked");
|
||||
boolean saved = data.getBoolean("saved");
|
||||
boolean deleted = post.getBoolean("deleted");
|
||||
String distinguished = creator.optBoolean("admin") ? "admin" : "";
|
||||
String distinguished = (isModerator) ? "moderator" : (isAdmin) ? "admin" : "";
|
||||
String suggestedSort = "";
|
||||
ArrayList<Post.Preview> previews = new ArrayList<>();
|
||||
if (!post.isNull("thumbnail_url")) {
|
||||
@ -642,6 +644,19 @@ public class ParsePost {
|
||||
return post;
|
||||
}
|
||||
|
||||
private boolean isModerator(JSONArray moderators, String username) {
|
||||
for (int i = 0; i < moderators.length(); i++) {
|
||||
try {
|
||||
if (moderators.getJSONObject(i).getString("name").equals(username)) {
|
||||
return true;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface ParsePostsListingListener {
|
||||
void onParsePostsListingSuccess(LinkedHashSet<Post> newPostData, String lastItem);
|
||||
void onParsePostsListingFail();
|
||||
|
Loading…
Reference in New Issue
Block a user