From 344ba62368965d02e5b95b19b4c3eeda44c30e34 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Thu, 29 Aug 2024 11:43:40 +0200 Subject: [PATCH] fix: Tolerate missing status fields on veganism.social (#911) veganism.social is doing something weird that injects statuses into the user's timeline that are missing the fields that are normally present on authenticated statuses. So far I've noticed: - `reblogged` - `favourited` - `bookmarked` on the top level `Status` are missing, and if the status contains a poll the `voted` field is also missing. Cover up this breakage by setting defaults for these fields. --- .../src/main/kotlin/app/pachli/core/network/model/Poll.kt | 2 +- .../src/main/kotlin/app/pachli/core/network/model/Status.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/network/src/main/kotlin/app/pachli/core/network/model/Poll.kt b/core/network/src/main/kotlin/app/pachli/core/network/model/Poll.kt index 2c405ff43..3513a9794 100644 --- a/core/network/src/main/kotlin/app/pachli/core/network/model/Poll.kt +++ b/core/network/src/main/kotlin/app/pachli/core/network/model/Poll.kt @@ -16,7 +16,7 @@ data class Poll( val options: List, // Friendica can incorrectly return null for `voted`. Default to false. // https://github.com/friendica/friendica/issues/13922 - @BooleanIfNull(false) val voted: Boolean, + @BooleanIfNull(false) val voted: Boolean = false, @Json(name = "own_votes") val ownVotes: List?, ) { diff --git a/core/network/src/main/kotlin/app/pachli/core/network/model/Status.kt b/core/network/src/main/kotlin/app/pachli/core/network/model/Status.kt index f0f37eaf4..62ad960e0 100644 --- a/core/network/src/main/kotlin/app/pachli/core/network/model/Status.kt +++ b/core/network/src/main/kotlin/app/pachli/core/network/model/Status.kt @@ -43,9 +43,9 @@ data class Status( @Json(name = "reblogs_count") val reblogsCount: Int, @Json(name = "favourites_count") val favouritesCount: Int, @Json(name = "replies_count") val repliesCount: Int, - val reblogged: Boolean, - val favourited: Boolean, - val bookmarked: Boolean, + val reblogged: Boolean = false, + val favourited: Boolean = false, + val bookmarked: Boolean = false, val sensitive: Boolean, @Json(name = "spoiler_text") val spoilerText: String, val visibility: Visibility,