Skip to content

Commit

Permalink
fix: Parse roles without a highlighted property (#467)
Browse files Browse the repository at this point in the history
The `highlighted` property on a role may be absent. If it is this breaks
account parsing, including accounts in an /api/v2/instance response.
This, in turn, breaks determining server capabilities, including whether
or not translation is supported.

Set the default to `true`, which matches observed Mastodon behaviour.
  • Loading branch information
nikclayton authored Feb 22, 2024
1 parent 415b182 commit 51c64a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/app/pachli/network/ServerRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class ServerRepository @Inject constructor(

mastodonApi.getInstanceV2().fold(
{ Server.from(nodeInfo.software, it).mapError(::Capabilities) },
{
{ throwable ->
Timber.e(throwable, "Couldn't process /api/v2/instance result")
mastodonApi.getInstanceV1().fold(
{ Server.from(nodeInfo.software, it).mapError(::Capabilities) },
{ Err(GetInstanceInfoV1(it)) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ data class Role(
val name: String,
/** Colour to use for the role badge, may be the empty string */
val color: String,
// Default value is true, since the property may be missing and the observed
// Mastodon behaviour when it is is to highlight the role. Also, this property
// being missing breaks InstanceV2 parsing.
// See https://github.com/mastodon/mastodon/issues/28327
/** True if the badge should be displayed on the account profile */
val highlighted: Boolean,
val highlighted: Boolean = true,
)

0 comments on commit 51c64a7

Please sign in to comment.