mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
added check to previously made backups
This commit is contained in:
parent
d9824b5b8a
commit
98c85d7eb2
1 changed files with 44 additions and 40 deletions
|
@ -79,19 +79,23 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
tmpDir.delete()
|
||||
}
|
||||
private class reposElements (
|
||||
@JsonProperty("full_name") var repoName: String
|
||||
@JsonProperty("full_name") var repoName: String,
|
||||
@JsonProperty("name") var shortRepoName: String
|
||||
|
||||
)
|
||||
|
||||
private suspend fun initLogin(githubToken: String): Boolean{
|
||||
val repoResponse = app.post("https://api.github.com/user/repos",
|
||||
val repoResponse = app.get("https://api.github.com/user/repos",
|
||||
headers= mapOf(
|
||||
"Accept" to "application/vnd.github+json",
|
||||
"Authorization" to "token $githubToken"
|
||||
)
|
||||
)
|
||||
if (repoResponse.isSuccessful) {
|
||||
if (!repoResponse.isSuccessful) {
|
||||
return false
|
||||
}
|
||||
val repo = tryParseJson<List<reposElements>>(repoResponse.text)?.filter {
|
||||
it.repoName == "sync-data-for-Cloudstream"
|
||||
it.shortRepoName == "sync-data-for-Cloudstream"
|
||||
}
|
||||
if (repo?.isEmpty() == true) {
|
||||
val response = app.post(
|
||||
|
@ -123,14 +127,14 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
return true
|
||||
}
|
||||
else{
|
||||
repo.first().let { {
|
||||
setKey(
|
||||
accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||
repo?.first().let {
|
||||
setKey(accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||
token = githubToken,
|
||||
repoUrl = it?.repoName?: run {
|
||||
return false
|
||||
})
|
||||
)
|
||||
}))
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue