use custom JsonAdapter to be compatible with instances that have a custom subscribing feature (#2298)

This commit is contained in:
Konrad Pozniak 2022-01-21 07:34:26 +01:00 committed by GitHub
commit 2fd01f7e2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 170 additions and 1 deletions

View file

@ -15,7 +15,9 @@
package com.keylesspalace.tusky.entity
import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName
import com.keylesspalace.tusky.json.GuardedBooleanAdapter
data class Relationship(
val id: String,
@ -26,7 +28,11 @@ data class Relationship(
@SerializedName("muting_notifications") val mutingNotifications: Boolean,
val requested: Boolean,
@SerializedName("showing_reblogs") val showingReblogs: Boolean,
val subscribing: Boolean? = null, // Pleroma extension
/* Pleroma extension, same as 'notifying' on Mastodon.
* Some instances like qoto.org have a custom subscription feature where 'subscribing' is a json object,
* so we use the custom GuardedBooleanAdapter to ignore the field if it is not a boolean.
*/
@JsonAdapter(GuardedBooleanAdapter::class) val subscribing: Boolean? = null,
@SerializedName("domain_blocking") val blockingDomain: Boolean,
val note: String?, // nullable for backward compatibility / feature detection
val notifying: Boolean? // since 3.3.0rc