From caf4f177d238cc7ee9f98d894ca3a1498b3a70ba Mon Sep 17 00:00:00 2001 From: Stefan Zwanenburg Date: Mon, 11 Sep 2023 11:09:46 +0200 Subject: [PATCH] Fix parsing posts and userdata: admin flag removed in recent versions of Lemmy See: https://github.com/LemmyNet/lemmy/pull/3403 For now, I guess we can try parsing the flag if it's present, and fall back on assuming the associated user is *not* an admin. --- app/src/main/java/eu/toldi/infinityforlemmy/post/ParsePost.java | 2 +- .../main/java/eu/toldi/infinityforlemmy/user/ParseUserData.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/post/ParsePost.java b/app/src/main/java/eu/toldi/infinityforlemmy/post/ParsePost.java index 7c46ec93..b090b328 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/post/ParsePost.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/post/ParsePost.java @@ -188,7 +188,7 @@ public class ParsePost { boolean nsfw = post.getBoolean("nsfw"); boolean locked = post.getBoolean("locked"); boolean saved = data.getBoolean("saved"); - String distinguished = (creator.getBoolean("admin") ? "admin" : ""); + String distinguished = creator.optBoolean("admin") ? "admin" : ""; String suggestedSort = ""; ArrayList previews = new ArrayList<>(); if (!post.isNull("thumbnail_url")) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/user/ParseUserData.java b/app/src/main/java/eu/toldi/infinityforlemmy/user/ParseUserData.java index 1836dfae..8bfa4247 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/user/ParseUserData.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/user/ParseUserData.java @@ -48,7 +48,7 @@ public class ParseUserData { boolean isBot = personJson.getBoolean("bot_account"); boolean isBanned = personJson.getBoolean("banned"); boolean isLocal = personJson.getBoolean("local"); - boolean isAdmin = personJson.getBoolean("admin"); + boolean isAdmin = personJson.optBoolean("admin"); boolean isDeleted = personJson.getBoolean("deleted"); String description = "";