mirror of
https://github.com/ReVanced/revanced-api.git
synced 2026-01-17 16:33:57 +00:00
feat: Add URL and use friendly name for APIContributable
This commit is contained in:
@@ -26,7 +26,7 @@ import kotlin.io.path.createDirectories
|
||||
* @property patches The source of the patches.
|
||||
* @property integrations The source of the integrations.
|
||||
* @property manager The source of the manager.
|
||||
* @property contributorsRepositoryNames The names of the repositories to get contributors from.
|
||||
* @property contributorsRepositoryNames The friendly name of repos mapped to the repository names to get contributors from.
|
||||
* @property backendServiceName The name of the backend service to use for the repositories, contributors, etc.
|
||||
* @property apiVersion The version to use for the API.
|
||||
* @property corsAllowedHosts The hosts allowed to make requests to the API.
|
||||
@@ -44,7 +44,7 @@ internal class ConfigurationRepository(
|
||||
val integrations: SignedAssetConfiguration,
|
||||
val manager: AssetConfiguration,
|
||||
@SerialName("contributors-repositories")
|
||||
val contributorsRepositoryNames: Set<String>,
|
||||
val contributorsRepositoryNames: Map<String, String>,
|
||||
@SerialName("backend-service-name")
|
||||
val backendServiceName: String,
|
||||
@SerialName("api-version")
|
||||
|
||||
@@ -35,6 +35,7 @@ class ApiContributor(
|
||||
@Serializable
|
||||
class APIContributable(
|
||||
val name: String,
|
||||
val url: String,
|
||||
// Using a list instead of a set because set semantics are unnecessary here.
|
||||
val contributors: List<ApiContributor>,
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package app.revanced.api.configuration.services
|
||||
import app.revanced.api.configuration.repository.BackendRepository
|
||||
import app.revanced.api.configuration.repository.ConfigurationRepository
|
||||
import app.revanced.api.configuration.schema.*
|
||||
import io.ktor.http.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
@@ -16,11 +17,15 @@ internal class ApiService(
|
||||
val about = configurationRepository.about
|
||||
|
||||
suspend fun contributors() = withContext(Dispatchers.IO) {
|
||||
configurationRepository.contributorsRepositoryNames.map {
|
||||
configurationRepository.contributorsRepositoryNames.map { (repository, name) ->
|
||||
async {
|
||||
APIContributable(
|
||||
it,
|
||||
backendRepository.contributors(configurationRepository.organization, it).map {
|
||||
name,
|
||||
URLBuilder().apply {
|
||||
takeFrom(backendRepository.website)
|
||||
path(configurationRepository.organization, repository)
|
||||
}.buildString(),
|
||||
backendRepository.contributors(configurationRepository.organization, repository).map {
|
||||
ApiContributor(it.name, it.avatarUrl, it.url, it.contributions)
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user