fix: more lemmy 0.19 breaking changes (#192)

This commit is contained in:
Diego Beraldin 2023-12-04 13:01:50 +01:00 committed by GitHub
parent 5b89911375
commit 2a31369894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 25 deletions

View File

@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class LocalSiteRateLimit( data class LocalSiteRateLimit(
@SerialName("id") val id: Int, @SerialName("id") val id: Int? = null,
@SerialName("local_site_id") val localSiteId: LocalSiteId, @SerialName("local_site_id") val localSiteId: LocalSiteId,
@SerialName("message") val message: Int, @SerialName("message") val message: Int,
@SerialName("message_per_second") val messagePerSecond: Int, @SerialName("message_per_second") val messagePerSecond: Int,

View File

@ -8,19 +8,19 @@ data class LocalUser(
@SerialName("id") val id: LocalUserId, @SerialName("id") val id: LocalUserId,
@SerialName("person_id") val personId: PersonId, @SerialName("person_id") val personId: PersonId,
@SerialName("email") val email: String? = null, @SerialName("email") val email: String? = null,
@SerialName("show_nsfw") val showNsfw: Boolean, @SerialName("show_nsfw") val showNsfw: Boolean? = null,
@SerialName("theme") val theme: String, @SerialName("theme") val theme: String? = null,
@SerialName("default_sort_type") val defaultSortType: SortType, @SerialName("default_sort_type") val defaultSortType: SortType? = null,
@SerialName("default_listing_type") val defaultListingType: ListingType, @SerialName("default_listing_type") val defaultListingType: ListingType? = null,
@SerialName("interface_language") val interfaceLanguage: String, @SerialName("interface_language") val interfaceLanguage: String? = null,
@SerialName("show_avatars") val showAvatars: Boolean, @SerialName("show_avatars") val showAvatars: Boolean? = null,
@SerialName("send_notifications_to_email") val sendNotificationsToEmail: Boolean, @SerialName("send_notifications_to_email") val sendNotificationsToEmail: Boolean? = null,
@SerialName("validator_time") val validatorTime: String, @SerialName("validator_time") val validatorTime: String? = null,
@SerialName("show_scores") val showScores: Boolean, @SerialName("show_scores") val showScores: Boolean? = null,
@SerialName("show_bot_accounts") val showBotAccounts: Boolean, @SerialName("show_bot_accounts") val showBotAccounts: Boolean? = null,
@SerialName("show_read_posts") val showReadPosts: Boolean, @SerialName("show_read_posts") val showReadPosts: Boolean? = null,
@SerialName("show_new_post_notifs") val showNewPostNotifs: Boolean, @SerialName("show_new_post_notifs") val showNewPostNotifs: Boolean? = null,
@SerialName("email_verified") val emailVerified: Boolean, @SerialName("email_verified") val emailVerified: Boolean? = null,
@SerialName("accepted_application") val acceptedApplication: Boolean, @SerialName("accepted_application") val acceptedApplication: Boolean? = null,
@SerialName("totp_2fa_url") val totp2faUrl: String? = null, @SerialName("totp_2fa_url") val totp2faUrl: String? = null,
) )

View File

@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class LocalUserView( data class LocalUserView(
@SerialName("local_user") val localUser: LocalUser, @SerialName("local_user") val localUser: LocalUser? = null,
@SerialName("person") val person: Person, @SerialName("person") val person: Person,
@SerialName("counts") val counts: PersonAggregates, @SerialName("counts") val counts: PersonAggregates,
) )

View File

@ -5,10 +5,10 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class MyUserInfo( data class MyUserInfo(
@SerialName("local_user_view") val localUserView: LocalUserView, @SerialName("local_user_view") val localUserView: LocalUserView? = null,
@SerialName("follows") val follows: List<CommunityFollowerView>, @SerialName("follows") val follows: List<CommunityFollowerView> = emptyList(),
@SerialName("moderates") val moderates: List<CommunityModeratorView>, @SerialName("moderates") val moderates: List<CommunityModeratorView> = emptyList(),
@SerialName("community_blocks") val communityBlocks: List<CommunityBlockView>, @SerialName("community_blocks") val communityBlocks: List<CommunityBlockView> = emptyList(),
@SerialName("person_blocks") val personBlocks: List<PersonBlockView>, @SerialName("person_blocks") val personBlocks: List<PersonBlockView> = emptyList(),
@SerialName("discussion_languages") val discussionLanguages: List<LanguageId>, @SerialName("discussion_languages") val discussionLanguages: List<LanguageId> = emptyList(),
) )

View File

@ -17,9 +17,9 @@ class SiteRepository(
authHeader = auth.toAuthHeader(), authHeader = auth.toAuthHeader(),
).body() ).body()
dto?.myUser?.let { dto?.myUser?.let {
val user = it.localUserView.person val user = it.localUserView?.person
val counts = it.localUserView.counts val counts = it.localUserView?.counts
user.toModel().copy(score = counts.toModel()) user?.toModel()?.copy(score = counts?.toModel())
} }
}.getOrNull() }.getOrNull()