Skip to content

Commit

Permalink
Changes for v1.0-beta-13.
Browse files Browse the repository at this point in the history
Merge changes for v1.0-beta-13.
  • Loading branch information
KotlinGeekDev authored Feb 19, 2025
2 parents e50f345 + 6611db1 commit 39c5de6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
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)"
}
}

0 comments on commit 39c5de6

Please sign in to comment.