From 526ee27a6a9e9c23bcc3d0e4f0b58c2dca903940 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 22 Jul 2024 16:22:01 +0200 Subject: [PATCH] fix: Enable server filtering on GoToSocial 0.16+ (#826) Previous code had the version test in the wrong order, so the check for >= 0.15.0 took precedence. --- .../kotlin/app/pachli/core/network/Server.kt | 8 +++-- .../app/pachli/core/network/ServerTest.kt | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/core/network/src/main/kotlin/app/pachli/core/network/Server.kt b/core/network/src/main/kotlin/app/pachli/core/network/Server.kt index af585db96..6bb095f9e 100644 --- a/core/network/src/main/kotlin/app/pachli/core/network/Server.kt +++ b/core/network/src/main/kotlin/app/pachli/core/network/Server.kt @@ -238,7 +238,7 @@ data class Server( } // Uses format "yyyy.mm.dd" with an optional ".beta..." suffix. - // https://git.joinsharkey.org/Sharkey/Sharkey/issues/371 + // https://activitypub.software/TransFem-org/Sharkey/-/issues/371 SHARKEY -> { val rx = """^(?\d+)\.(?\d+)\.(?\d+)""".toRegex() rx.find(version).toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } @@ -265,20 +265,22 @@ data class Server( v >= "2.4.3".toVersion() -> c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.0.0".toVersion() } + // Server side filtering when { v >= "4.0.0".toVersion() -> c[ORG_JOINMASTODON_FILTERS_SERVER] = "1.0.0".toVersion() } } GOTOSOCIAL -> { + // Filters when { - // Implemented in https://github.com/superseriousbusiness/gotosocial/pull/2594 - v >= "0.15.0".toVersion() -> c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.1.0".toVersion() // Implemented in https://github.com/superseriousbusiness/gotosocial/pull/2936 v >= "0.16.0".toVersion() -> { c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.1.0".toVersion() c[ORG_JOINMASTODON_FILTERS_SERVER] = "1.0.0".toVersion() } + // Implemented in https://github.com/superseriousbusiness/gotosocial/pull/2594 + v >= "0.15.0".toVersion() -> c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.1.0".toVersion() } } diff --git a/core/network/src/test/kotlin/app/pachli/core/network/ServerTest.kt b/core/network/src/test/kotlin/app/pachli/core/network/ServerTest.kt index d2b659d0d..fff3c1dd2 100644 --- a/core/network/src/test/kotlin/app/pachli/core/network/ServerTest.kt +++ b/core/network/src/test/kotlin/app/pachli/core/network/ServerTest.kt @@ -195,6 +195,39 @@ class ServerTest( ), ), ), + arrayOf( + Triple( + "GoToSocial 0.15.0 has client filters", + NodeInfo.Software("gotosocial", "0.15.0 git-ccecf5a"), + defaultInstance, + ), + Ok( + Server( + kind = GOTOSOCIAL, + version = "0.15.0".toVersion(), + capabilities = mapOf( + ORG_JOINMASTODON_FILTERS_CLIENT to "1.1.0".toVersion(), + ), + ), + ), + ), + arrayOf( + Triple( + "GoToSocial 0.16.0 has server filters", + NodeInfo.Software("gotosocial", "0.16.0 git-ccecf5a"), + defaultInstance, + ), + Ok( + Server( + kind = GOTOSOCIAL, + version = "0.16.0".toVersion(), + capabilities = mapOf( + ORG_JOINMASTODON_FILTERS_CLIENT to "1.1.0".toVersion(), + ORG_JOINMASTODON_FILTERS_SERVER to "1.0.0".toVersion(), + ), + ), + ), + ), arrayOf( Triple( "Pleroma can filter",