Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c52addb
Only retry GET requests on network errors
MV-GH Nov 18, 2026
d2e80d3
Use http for localhost instances with a port
MV-GH Nov 18, 2026
8bb08d7
Clean up uploaded image when applying it is cancelled
MV-GH Nov 18, 2026
8e64b7c
Fix registration invitations for v1
MV-GH Nov 18, 2026
27b4379
Support post notifications on v1
MV-GH Nov 18, 2026
d9dc90e
Implement hidePosts for v1 by hiding posts one by one
MV-GH Nov 18, 2026
5815fbe
Map admin flags from the person on 0.18
MV-GH Nov 18, 2026
cd6adc6
Add timezone to all 0.18 timestamps
MV-GH Nov 18, 2026
32111a3
Fix report count on 0.18
MV-GH Nov 18, 2026
252d547
Keep current values on partial custom emoji edits pre v1
MV-GH Nov 18, 2026
a919e7f
Replace enable_nsfw with nsfw_content_disallowed in EditSite
MV-GH Nov 18, 2026
fd03a12
Stop markManyPostsAsRead at the first failure on 0.18
MV-GH Nov 18, 2026
fad14d4
Map max_depth in GetComments on 0.19.2 and 0.19.3
MV-GH Nov 18, 2026
1f2f358
Map animated_images_enabled in SaveUserSettings on 0.19.2 and 0.19.3
MV-GH Nov 18, 2026
0431f1b
Map post_id when listing post reports on 0.19.4 and 0.19.5
MV-GH Nov 18, 2026
543ed11
Map comment report resolver on 0.19.11
MV-GH Nov 18, 2026
df37d2b
Map subscribers_local on 0.19.6 and later
MV-GH Nov 18, 2026
91e60cf
Apply post and community filters to all report types pre v1
MV-GH Nov 18, 2026
dfa5ca3
Return no next page for legacy comment tree fetches
MV-GH Nov 18, 2026
acd8588
Add feature flags for v1 only endpoints
MV-GH Nov 18, 2026
7369e29
Add e2e tests for reports and moderation
MV-GH Nov 18, 2026
2346b1c
Fix deleteCustomEmoji route for v1
MV-GH Nov 18, 2026
0a3cbb3
Remove leaveAdmin
MV-GH Nov 18, 2026
6137859
Add e2e tests for admin site management
MV-GH Nov 18, 2026
5624799
Add e2e tests for multi communities
MV-GH Nov 18, 2026
4d224f1
Run e2e tests that ended with assertNotNull
MV-GH Nov 18, 2026
afba84a
Compare publish times in the post sort order e2e test
MV-GH Nov 18, 2026
79d7557
Remove hideCommunity, map Unlisted visibility to hiding pre v1
MV-GH Nov 18, 2026
ec1dd2d
Fix resolveObject for v1, return ResolveObjectView
MV-GH Nov 18, 2026
147ac83
Release 1.0.0-rc.4
MV-GH Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

All notable changes to this project are documented here.

## [1.0.0-rc.4] - 2026-11-18

### Breaking changes

- `EditSite.enable_nsfw` was removed, as it was in 1.0. Use its inverse `nsfw_content_disallowed`, which now also works on 0.18 and 0.19.
- `leaveAdmin` was removed, as it was in 1.0. Use `addAdmin(AddAdmin(person_id, added = false))` instead.
- `hideCommunity` and `HideCommunity` were removed, as they were in 1.0. Use `createCommunity` or `editCommunity` with `visibility = CommunityVisibility.Unlisted`. On 0.18 and 0.19 this hides the community (admins only), and `Public` unhides it. `Public` and `Unlisted` are now supported entries from 0.18.

### Added

- Feature flags `instanceBlockPersons()`, `modlog()` and `listPersonReadHiddenLiked()` for endpoints that only work on Lemmy 1.0.
- `hidePosts` works on Lemmy 1.0 by hiding the posts one by one.

### Fixed

- Only GET requests are retried after network errors, so POST/PUT/DELETE requests are no longer sent twice.
- `localhost:<port>` and `127.0.0.1:<port>` instances use http.
- An uploaded image is deleted again when applying it is cancelled.
- Creating and listing registration invitations works on Lemmy 1.0 (wrong list route, and responses failed to deserialize).
- Post notifications no longer make `listNotifications` fail on Lemmy 1.0.
- `deleteCustomEmoji` uses the correct route on Lemmy 1.0.
- `resolveObject` works on Lemmy 1.0.
- Lemmy 0.18: admins are reported as admins (`is_admin`, `local_user.admin`, `creator_is_admin`).
- Lemmy 0.18: all timestamps have a timezone.
- Lemmy 0.18: the report count no longer counts comment reports twice, and is null when it isn't available.
- Pre-1.0: partial `editCustomEmoji` edits keep the current values instead of crashing (0.18) or blanking them (0.19).
- Lemmy 0.18: `markManyPostsAsRead` stops at the first failure.
- Lemmy 0.19.2-0.19.3: `GetComments.max_depth` and `SaveUserSettings.animated_images_enabled` are sent.
- Lemmy 0.19.4-0.19.5: `listReports` filters post reports by `post_id`.
- Lemmy 0.19.11: comment reports include their `resolver`.
- Lemmy 0.19.6+: `subscribers_local` is filled in.
- Pre-1.0: `listReports` with `post_id` or `community_id` no longer returns unrelated post, comment or private message reports, and paging continues past pages without matches.
- Pre-1.0: `getComments` with `max_depth` returns no `next_page`, because the server always returns the whole tree.

## [1.0.0-rc.3] - 2026-11-17

### Breaking changes
Expand Down
3 changes: 0 additions & 3 deletions GeneratorScripts/src/main/kotlin/MapperGenerator0x18x5.kt
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,6 @@ internal interface MapperGenerator0x18x5 {

fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata

@Konvert(mappings = [Mapping(target = "auth", constant = "auth")])
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity

@Konvert(mappings = [Mapping(target = "auth", constant = "auth")])
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities

Expand Down
1 change: 0 additions & 1 deletion GeneratorScripts/src/main/kotlin/MapperGenerator0x19x0.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ internal interface MapperGenerator0x19x0 {
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPost): GetPost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPosts): GetPosts
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListRegistrationApplications): ListRegistrationApplications
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.LockPost): LockPost
Expand Down
1 change: 0 additions & 1 deletion GeneratorScripts/src/main/kotlin/MapperGenerator0x19x11.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ internal interface MapperGenerator0x19x11 {
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPosts): GetPosts
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetRegistrationApplication): GetRegistrationApplication
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HidePost): HidePost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommentLikes): ListCommentLikes
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities
Expand Down
1 change: 0 additions & 1 deletion GeneratorScripts/src/main/kotlin/MapperGenerator0x19x3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ internal interface MapperGenerator0x19x3 {
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPost): GetPost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPosts): GetPosts
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommentLikes): ListCommentLikes
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListPostLikes): ListPostLikes
Expand Down
1 change: 0 additions & 1 deletion GeneratorScripts/src/main/kotlin/MapperGenerator0x19x4.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ internal interface MapperGenerator0x19x4 {
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPost): GetPost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPosts): GetPosts
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HidePost): HidePost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommentLikes): ListCommentLikes
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities
Expand Down
1 change: 0 additions & 1 deletion GeneratorScripts/src/main/kotlin/MapperGenerator0x19x6.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ internal interface MapperGenerator0x19x6 {
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetPosts): GetPosts
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetRegistrationApplication): GetRegistrationApplication
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HidePost): HidePost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommentLikes): ListCommentLikes
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities
Expand Down
2 changes: 1 addition & 1 deletion GeneratorScripts/src/main/kotlin/MapperGenerator1x0x0.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ internal interface MapperGenerator1x0x0 {

fun toUni(d: NotificationData): it.vercruysse.lemmyapi.datatypes.NotificationData = when (d) {
is CommentView -> toUni(d)
is PostView -> toUni(d)
is ModlogView -> toUni(d)
is PrivateMessageView -> toUni(d)
}
Expand Down Expand Up @@ -240,7 +241,6 @@ internal interface MapperGenerator1x0x0 {
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetRandomCommunity): GetRandomCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetRegistrationApplication): GetRegistrationApplication
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.GetSiteMetadata): GetSiteMetadata
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HideCommunity): HideCommunity
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.HidePost): HidePost
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommentLikes): ListCommentLikes
fun fromUni(d: it.vercruysse.lemmyapi.datatypes.ListCommunities): ListCommunities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ val sealedImplementations = mapOf(
"Post" to SealedImpl("post", listOf("PostOrCommentOrPrivateMessage")),
"PrivateMessage" to SealedImpl("private_message", listOf("PostOrCommentOrPrivateMessage")),
"CommentView" to SealedImpl("comment", listOf("ResolveObjectView", "NotificationData", "PostCommentCombinedView")),
"PostView" to SealedImpl("post", listOf("ResolveObjectView", "PostCommentCombinedView")),
"PostView" to SealedImpl("post", listOf("ResolveObjectView", "NotificationData", "PostCommentCombinedView")),
"CommunityView" to SealedImpl("community", listOf("ResolveObjectView")),
"PersonView" to SealedImpl("person", listOf("ResolveObjectView")),
"MultiCommunityView" to SealedImpl("multi_community", listOf("ResolveObjectView")),
Expand Down
24 changes: 24 additions & 0 deletions app/src/commonMain/kotlin/it/vercruysse/lemmyapi/FeatureFlags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,31 @@ class FeatureFlags(val version: LemmyVersion) {
/**
* InstanceBlock Feature added in 0.19
*
* Endpoint `userBlockInstanceCommunities`, see [instanceBlockPersons] for `userBlockInstancePersons`
*/
fun instanceBlock(): Boolean = v0x19Plus

/**
* Block the persons of an instance, feature added in 1.0
*
* Endpoint `userBlockInstancePersons`
*/
fun instanceBlockPersons(): Boolean = v1

/**
* Modlog, supported from 1.0
*
* Endpoint `getModlog`
*/
fun modlog(): Boolean = v1

/**
* Read, hidden and liked content lists, feature added in 1.0
*
* Endpoint `listPersonRead` + `listPersonHidden` + `listPersonLiked`
*/
fun listPersonReadHiddenLiked(): Boolean = v1

/**
* TOTP Rework Feature added in 0.19
*
Expand Down Expand Up @@ -67,6 +89,8 @@ class FeatureFlags(val version: LemmyVersion) {

/**
* Hide posts, feature added in 0.19.4
*
* Endpoint `hidePost` + `hidePosts`
*/
fun hidePost(): Boolean = v0x19x4Plus

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package it.vercruysse.lemmyapi

import io.ktor.client.*
import io.ktor.client.network.sockets.ConnectTimeoutException
import io.ktor.client.network.sockets.SocketTimeoutException
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.statement.*
Expand All @@ -9,6 +11,7 @@ import io.ktor.serialization.kotlinx.json.*
import it.vercruysse.lemmyapi.dto.ErrorResponse
import it.vercruysse.lemmyapi.exception.LemmyBadRequestException
import kotlinx.serialization.SerializationException
import kotlin.coroutines.cancellation.CancellationException

internal fun HttpClient.withLemmyApiConfig(options: LemmyApiOptions): HttpClient = config {
installRequiredPlugins(options)
Expand Down Expand Up @@ -55,6 +58,10 @@ internal fun HttpClientConfig<*>.installRequiredPlugins(options: LemmyApiOptions
retryIf { req, response ->
response.status.value >= 500 && req.method == HttpMethod.Get
}
// The default also retries non-idempotent requests on network errors, which can duplicate them
retryOnExceptionIf { req, cause ->
req.method == HttpMethod.Get && cause !is CancellationException && !cause.isTimeout()
}
exponentialDelay()
}

Expand All @@ -63,4 +70,7 @@ internal fun HttpClientConfig<*>.installRequiredPlugins(options: LemmyApiOptions
}
}

private fun Throwable.isTimeout(): Boolean =
this is HttpRequestTimeoutException || this is ConnectTimeoutException || this is SocketTimeoutException

internal typealias AuthProvider = () -> String?
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package it.vercruysse.lemmyapi

import it.vercruysse.lemmyapi.datatypes.DeleteImageParams
import it.vercruysse.lemmyapi.datatypes.EditCustomEmoji
import it.vercruysse.lemmyapi.datatypes.GetCommunity
import it.vercruysse.lemmyapi.datatypes.ListCustomEmojis
import it.vercruysse.lemmyapi.datatypes.UploadImageResponse
import it.vercruysse.lemmyapi.enums.CommunityVisibility
import it.vercruysse.lemmyapi.enums.VersionTracker
import it.vercruysse.lemmyapi.exception.LemmyBadRequestException
import it.vercruysse.lemmyapi.exception.NotSupportedException
import it.vercruysse.lemmyapi.utils.getSupportedEntries
import it.vercruysse.lemmyapi.utils.runCatchingPreservingCancellation
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.withContext

abstract class LemmyApiBaseController(
val instance: LemmyInstance,
Expand Down Expand Up @@ -51,8 +58,42 @@ abstract class LemmyApiBaseController(
applyImage(uploadResponse.image_url).getOrThrow()
uploadResponse
} catch (e: Throwable) {
deleteMedia(DeleteImageParams(uploadResponse.delete_filename)).getOrNull()
withContext(NonCancellable) {
deleteMedia(DeleteImageParams(uploadResponse.delete_filename)).getOrNull()
}
throw e
}
}

// Pre 1.0 edits overwrite every field, so fill the ones not given with the current values
internal suspend fun withCurrentCustomEmoji(form: EditCustomEmoji): EditCustomEmoji {
if (form.category != null && form.image_url != null && form.alt_text != null && form.keywords != null) return form
val current = listCustomEmojis(ListCustomEmojis()).getOrThrow().custom_emojis
.firstOrNull { it.custom_emoji.id == form.id }
?: throw IllegalArgumentException("Custom emoji ${form.id} not found")
return form.copy(
category = form.category ?: current.custom_emoji.category,
image_url = form.image_url ?: current.custom_emoji.image_url,
alt_text = form.alt_text ?: current.custom_emoji.alt_text,
keywords = form.keywords ?: current.keywords.map { it.keyword },
)
}

// Pre 1.0 Unlisted is the hidden flag. Returns the hidden state a visibility asks for, null to leave it as is.
internal fun legacyHidden(visibility: CommunityVisibility?): Boolean? = when (visibility) {
CommunityVisibility.Unlisted -> true
CommunityVisibility.Public -> false
CommunityVisibility.LocalOnly -> if (version.semanticVersion >= V0_19_4) false else null
else -> null
}

// Only admins can hide a community pre 1.0, check it before anything is created or edited
internal suspend fun checkCanChangeHidden() {
if (!getMyUser().getOrThrow().local_user_view.local_user.admin) {
throw LemmyBadRequestException(400, "not_an_admin", "Only admins can hide or unhide a community before Lemmy 1.0")
}
}

internal suspend fun isHidden(communityId: Long): Boolean =
getCommunity(GetCommunity(id = communityId)).getOrThrow().community_view.community.visibility == CommunityVisibility.Unlisted
}
16 changes: 1 addition & 15 deletions app/src/commonMain/kotlin/it/vercruysse/lemmyapi/UniRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface UniRoutes {
*
* @GET("resolve_object")
*/
suspend fun resolveObject(form: ResolveObject): Result<SearchResponse>
suspend fun resolveObject(form: ResolveObject): Result<ResolveObjectView>

/**
* Get / fetch a community.
Expand All @@ -79,13 +79,6 @@ interface UniRoutes {
*/
suspend fun editCommunity(form: EditCommunity): Result<CommunityResponse>

/**
* Hide a community from public / "All" view. Admins only.
*
* @PUT("community/hide")
*/
suspend fun hideCommunity(form: HideCommunity): Result<Unit>

/**
* List communities, with various filters.
*
Expand Down Expand Up @@ -495,13 +488,6 @@ interface UniRoutes {
*/
suspend fun verifyEmail(form: VerifyEmail): Result<Unit>

/**
* Leave the Site admins.
*
* @POST("user/leave_admin")
*/
suspend fun leaveAdmin(): Result<GetSiteResponse>

/**
* Mark the donation dialog as shown, so it isn't displayed anymore.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ data class EditSite(
val name: String? = null,
val sidebar: String? = null,
val summary: String? = null,
/** Removed in 1.0.0 */
val enable_nsfw: Boolean? = null,
val community_creation_admin_only: Boolean? = null,
val email_verification_required: Boolean? = null,
val application_question: String? = null,
Expand Down Expand Up @@ -83,7 +81,6 @@ data class EditSite(
val default_comment_downvotes: VoteSettings? /* "All" | "Local" | "Subscribed" | "Disable" */ = null,
/** Added in 1.0.0 */
val suggested_multi_community_id: MultiCommunityId? = null,
/** Added in 1.0.0 */
val nsfw_content_disallowed: Boolean? = null,
/** Added in 1.0.0 */
val email_notifications_disabled: Boolean? = null,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import kotlinx.serialization.Serializable
@CommonParcelize
@Serializable
data class LocalUserInvite(
val id: InvitationId,
val token: String,
val local_user_id: LocalUserId,
val max_uses: Long? = null,
val uses_count: Long,
val expires_at: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.vercruysse.lemmyapi.enums

import io.github.z4kn4fein.semver.Version
import it.vercruysse.lemmyapi.MINIMUM_API_VERSION
import it.vercruysse.lemmyapi.V0_19_4
import it.vercruysse.lemmyapi.V1_0_0
import kotlinx.serialization.SerialName
Expand All @@ -10,13 +11,14 @@ import kotlinx.serialization.Serializable
enum class CommunityVisibility(override val minimumVersion: Version = V0_19_4, override val maximumVersion: Version? = null) :
VersionTracker {
@SerialName("public")
Public,
Public(MINIMUM_API_VERSION),

@SerialName("local_only")
LocalOnly(V0_19_4, V1_0_0),

// Pre 1.0 this is the hidden flag
@SerialName("unlisted")
Unlisted(V1_0_0),
Unlisted(MINIMUM_API_VERSION),

@SerialName("local_only_public")
LocalOnlyPublic(V1_0_0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ internal fun constructBaseUrl(instance: String): String {
} else {
// Really basic heuristic to determine if it's http or https,
// if wrong, consumer should specify protocol
val protocol = if (instanceUrl.equals("localhost", true)) {
val host = instanceUrl.substringBefore('/').substringBefore(':')
val protocol = if (host.equals("localhost", true) || host == "127.0.0.1") {
URLProtocol.HTTP
} else {
URLProtocol.HTTPS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ internal object LegacyPaging {
/**
* Like [paged], for fetches that already build a [PagedResponse], for example by combining several requests.
* Its cursors are replaced by synthetic ones.
*
* [filter] is applied after the cursors are set, so a page that is filtered down to nothing doesn't end the paging.
*/
suspend fun <T : DatatypeRoot> pagedResponse(
cursor: PaginationCursor?,
filter: (T) -> Boolean = { true },
fetch: suspend (page: Long) -> Result<PagedResponse<T>>,
): Result<PagedResponse<T>> = withPage(cursor) { page ->
fetch(page).map { it.copy(next_page = next(page, it.items.isNotEmpty()), prev_page = prev(page)) }
fetch(page).map { it.copy(items = it.items.filter(filter), next_page = next(page, it.items.isNotEmpty()), prev_page = prev(page)) }
}
}
Loading
Loading