mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixes
This commit is contained in:
parent
df54745294
commit
d9824b5b8a
1 changed files with 42 additions and 20 deletions
|
@ -78,7 +78,7 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
.call();
|
||||
tmpDir.delete()
|
||||
}
|
||||
private class repos (
|
||||
private class reposElements (
|
||||
@JsonProperty("full_name") var repoName: String
|
||||
)
|
||||
|
||||
|
@ -89,28 +89,50 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
"Authorization" to "token $githubToken"
|
||||
)
|
||||
)
|
||||
val
|
||||
val response = app.post("https://api.github.com/user/repos",
|
||||
if (repoResponse.isSuccessful) {
|
||||
val repo = tryParseJson<List<reposElements>>(repoResponse.text)?.filter {
|
||||
it.repoName == "sync-data-for-Cloudstream"
|
||||
}
|
||||
if (repo?.isEmpty() == true) {
|
||||
val response = app.post(
|
||||
"https://api.github.com/user/repos",
|
||||
headers = mapOf(
|
||||
"Accept" to "application/vnd.github+json",
|
||||
"Authorization" to "token $githubToken"
|
||||
),
|
||||
requestBody = """{"name":"sync data for Cloudstream", "description": "Private repo for cloudstream Account", "private": true}""".toRequestBody(
|
||||
RequestBodyTypes.JSON.toMediaTypeOrNull()))
|
||||
RequestBodyTypes.JSON.toMediaTypeOrNull()
|
||||
)
|
||||
)
|
||||
|
||||
if (!response.isSuccessful) {return false}
|
||||
if (!response.isSuccessful) {
|
||||
return false
|
||||
}
|
||||
|
||||
val repoUrl = tryParseJson<repodata>(response.text).let {
|
||||
setKey(accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||
setKey(
|
||||
accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||
token = githubToken,
|
||||
repoUrl = it?.repoUrl ?: run {
|
||||
return false
|
||||
}))
|
||||
})
|
||||
)
|
||||
it.repoUrl
|
||||
}
|
||||
commitFile(repoUrl, githubToken)
|
||||
return true
|
||||
}
|
||||
else{
|
||||
repo.first().let { {
|
||||
setKey(
|
||||
accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||
token = githubToken,
|
||||
repoUrl = it?.repoName ?: run {
|
||||
return false
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun login(data: InAppAuthAPI.LoginData): Boolean {
|
||||
switchToNewAccount()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue