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.
This commit is contained in:
Nik Clayton 2024-07-22 16:22:01 +02:00 committed by GitHub
parent 92e5304b84
commit 526ee27a6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 3 deletions

View File

@ -238,7 +238,7 @@ data class Server(
} }
// Uses format "yyyy.mm.dd" with an optional ".beta..." suffix. // 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 -> { SHARKEY -> {
val rx = """^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)""".toRegex() val rx = """^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)""".toRegex()
rx.find(version).toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } 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() v >= "2.4.3".toVersion() -> c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.0.0".toVersion()
} }
// Server side filtering
when { when {
v >= "4.0.0".toVersion() -> c[ORG_JOINMASTODON_FILTERS_SERVER] = "1.0.0".toVersion() v >= "4.0.0".toVersion() -> c[ORG_JOINMASTODON_FILTERS_SERVER] = "1.0.0".toVersion()
} }
} }
GOTOSOCIAL -> { GOTOSOCIAL -> {
// Filters
when { 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 // Implemented in https://github.com/superseriousbusiness/gotosocial/pull/2936
v >= "0.16.0".toVersion() -> { v >= "0.16.0".toVersion() -> {
c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.1.0".toVersion() c[ORG_JOINMASTODON_FILTERS_CLIENT] = "1.1.0".toVersion()
c[ORG_JOINMASTODON_FILTERS_SERVER] = "1.0.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()
} }
} }

View File

@ -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( arrayOf(
Triple( Triple(
"Pleroma can filter", "Pleroma can filter",