๐Ÿ”— Redirect Bluesky links to your preferred client
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add bridgyfed support for Mastodon Redirect and fix GQL request

+19 -14
+1
mastodonredirect/src/main/java/dev/zwander/mastodonredirect/util/FetchInstancesActivity.kt
··· 21 21 "pixelfed", 22 22 "sharkey", 23 23 "wildebeest", 24 + "bridgyfed", 24 25 ) 25 26 }
-1
shared/src/main/graphql/GetInstances.graphql
··· 7 7 uptime_alltime 8 8 status 9 9 date_diedoff 10 - sslvalid 11 10 local_posts 12 11 protocols 13 12 score
+18 -13
shared/src/main/java/dev/zwander/shared/BaseFetchActivity.kt
··· 1 1 package dev.zwander.shared 2 2 3 + import android.util.Log 3 4 import androidx.activity.compose.rememberLauncherForActivityResult 4 5 import androidx.activity.result.contract.ActivityResultContracts 5 6 import androidx.compose.foundation.layout.Column ··· 20 21 import androidx.compose.ui.Modifier 21 22 import com.apollographql.apollo.ApolloClient 22 23 import dev.zwander.shared.generated.GetInstancesQuery 24 + import kotlinx.coroutines.Dispatchers 25 + import kotlinx.coroutines.withContext 23 26 import java.util.TreeSet 24 27 25 28 data class FetchedInstance( ··· 30 33 } 31 34 } 32 35 36 + private val userAndPostCountBypassHosts = arrayOf( 37 + "fed.brid.gy", 38 + ) 39 + 33 40 abstract class BaseFetchActivity : BaseActivity() { 34 41 protected val client by lazy { 35 42 ApolloClient.Builder() ··· 56 63 } 57 64 58 65 LaunchedEffect(key1 = null) { 59 - items = loadInstances().filter { 60 - it.name.isNotBlank() && !it.name.startsWith(".") && it.name.contains(".") 66 + withContext(Dispatchers.IO) { 67 + items = loadInstances().filter { 68 + it.name.isNotBlank() && !it.name.startsWith(".") && it.name.contains(".") 69 + } 61 70 } 62 71 } 63 72 ··· 90 99 91 100 val response = client.query(GetInstancesQuery()).execute() 92 101 102 + Log.e("Redirect", "${response.errors}") 103 + 93 104 response.data?.nodes?.mapNotNull { node -> 94 105 if (node == null) { 95 106 return@mapNotNull null ··· 99 110 return@mapNotNull null 100 111 } 101 112 102 - if (node.active_users_monthly == null || node.active_users_monthly <= 0) { 113 + if (node.domain == null) { 103 114 return@mapNotNull null 104 115 } 105 116 106 - // if (node.date_diedoff != null) { 107 - // return@mapNotNull null 108 - // } 117 + val isBypassHost = userAndPostCountBypassHosts.contains(node.domain) 109 118 110 - if (node.domain == null) { 119 + if (!isBypassHost && (node.active_users_monthly == null || node.active_users_monthly <= 0)) { 111 120 return@mapNotNull null 112 121 } 113 122 114 - if (node.total_users == null || node.total_users < 1) { 123 + if (!isBypassHost && (node.total_users == null || node.total_users < 1)) { 115 124 return@mapNotNull null 116 125 } 117 126 ··· 127 136 return@mapNotNull null 128 137 } 129 138 130 - if (!node.sslvalid.isNullOrBlank() && node.sslvalid != "true") { 131 - return@mapNotNull null 132 - } 133 - 134 - if (node.local_posts == null || node.local_posts < 1) { 139 + if (!isBypassHost && (node.local_posts == null || node.local_posts < 1)) { 135 140 return@mapNotNull null 136 141 } 137 142