Skip to content

Commit

Permalink
Info Queries (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 authored Aug 3, 2023
1 parent e275420 commit 06d7a6d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ object AppUpdate {
val stableJson = json.parseToJsonElement(
network.client.newCall(
GET(LATEST_STABLE_CHANNEL_URL)
).await().body!!.string()
).await().body.string()
).jsonObject

val previewJson = json.parseToJsonElement(
network.client.newCall(
GET(LATEST_PREVIEW_CHANNEL_URL)
).await().body!!.string()
).await().body.string()
).jsonObject

return listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package suwayomi.tachidesk.graphql.queries

import suwayomi.tachidesk.global.impl.AppUpdate
import suwayomi.tachidesk.server.BuildConfig
import suwayomi.tachidesk.server.JavalinSetup.future
import java.util.concurrent.CompletableFuture

class InfoQuery {
data class AboutPayload(
val name: String,
val version: String,
val revision: String,
val buildType: String,
val buildTime: Long,
val github: String,
val discord: String
)

fun about(): AboutPayload {
return AboutPayload(
BuildConfig.NAME,
BuildConfig.VERSION,
BuildConfig.REVISION,
BuildConfig.BUILD_TYPE,
BuildConfig.BUILD_TIME,
BuildConfig.GITHUB,
BuildConfig.DISCORD
)
}

data class CheckForUpdatesPayload(
/** [channel] mirrors [suwayomi.tachidesk.server.BuildConfig.BUILD_TYPE] */
val channel: String,
val tag: String,
val url: String
)

fun checkForUpdates(): CompletableFuture<List<CheckForUpdatesPayload>> {
return future {
AppUpdate.checkUpdate().map {
CheckForUpdatesPayload(
channel = it.channel,
tag = it.tag,
url = it.url
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import suwayomi.tachidesk.graphql.queries.CategoryQuery
import suwayomi.tachidesk.graphql.queries.ChapterQuery
import suwayomi.tachidesk.graphql.queries.DownloadQuery
import suwayomi.tachidesk.graphql.queries.ExtensionQuery
import suwayomi.tachidesk.graphql.queries.InfoQuery
import suwayomi.tachidesk.graphql.queries.MangaQuery
import suwayomi.tachidesk.graphql.queries.MetaQuery
import suwayomi.tachidesk.graphql.queries.SourceQuery
Expand Down Expand Up @@ -61,6 +62,7 @@ val schema = toSchema(
TopLevelObject(ChapterQuery()),
TopLevelObject(DownloadQuery()),
TopLevelObject(ExtensionQuery()),
TopLevelObject(InfoQuery()),
TopLevelObject(MangaQuery()),
TopLevelObject(MetaQuery()),
TopLevelObject(SourceQuery()),
Expand Down

0 comments on commit 06d7a6d

Please sign in to comment.