Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes for v1.0-beta-13. #31

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You can include the library from either Maven Central or Jitpack.
You can include the library in the common source set like this:
```kotlin
dependencies {
implementation("io.github.kotlingeekdev:rhodium:1.0-beta-12")
implementation("io.github.kotlingeekdev:rhodium:1.0-beta-13")

}
```
Expand Down Expand Up @@ -74,7 +74,7 @@ then, in your module's `build.gradle(.kts)`, you need to add:
// build.gradle.kts
dependencies {
//...
implementation("com.github.KotlinGeekDev.Rhodium:rhodium:1.0-beta-12")
implementation("com.github.KotlinGeekDev.Rhodium:rhodium:1.0-beta-13")


}
Expand All @@ -85,7 +85,7 @@ If you're including it in an Android app, you can just add:
// app/build.gradle.kts
dependencies {
//...
implementation("com.github.KotlinGeekDev.Rhodium:rhodium-android:1.0-beta-12")
implementation("com.github.KotlinGeekDev.Rhodium:rhodium-android:1.0-beta-13")

}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {
val isJitpack = System.getenv("JITPACK") == "true"

group = "io.github.kotlingeekdev"
version = "1.0-beta-12"
version = "1.0-beta-13"


// val javadocJar = tasks.register<Jar>("javadocJar") {
Expand Down
29 changes: 29 additions & 0 deletions rhodium-core/src/commonMain/kotlin/rhodium/net/NostrService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,35 @@ class NostrService(
return potentialResults.maxBy { it.creationDate }
}

suspend fun fetchRelayListFor(profileHex: String, fetchRelays: List<String>): List<Relay> {
val relayListRequest = RequestMessage.singleFilterRequest(
filter = NostrFilter.newFilter()
.kinds(EventKind.RELAY_LIST.kind)
.authors(profileHex)
.limit(1)
.build()
)
val potentialResults = if (fetchRelays.isEmpty())
requestWithResult(relayListRequest) else requestWithResult(relayListRequest, fetchRelays.map { Relay(it) })

val mostUpdatedRelayList = potentialResults.maxBy { it.creationDate }
val potentialRelays = mostUpdatedRelayList.tags.filter { tag -> tag.identifier == "r" }
if (potentialRelays.isEmpty()) {
return emptyList()
}
else {
val relays = potentialRelays.map { relayTag ->
Relay(
relayTag.description,
readPolicy = if (relayTag.content == null) true else relayTag.content.contentEquals("read"),
writePolicy = if (relayTag.content == null) true else relayTag.content.contentEquals("write")
)
}

return relays
}
}

fun clearRelayPool() {
relayPool.clearPool()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ class Relay(
return Relay(address)
}
}

override fun toString(): String {
return "Relay(url=$relayURI, read=$readPolicy, write=$writePolicy)"
}
}