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();
|
.call();
|
||||||
tmpDir.delete()
|
tmpDir.delete()
|
||||||
}
|
}
|
||||||
private class repos (
|
private class reposElements (
|
||||||
@JsonProperty("full_name") var repoName: String
|
@JsonProperty("full_name") var repoName: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -89,28 +89,50 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
||||||
"Authorization" to "token $githubToken"
|
"Authorization" to "token $githubToken"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val
|
if (repoResponse.isSuccessful) {
|
||||||
val response = app.post("https://api.github.com/user/repos",
|
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(
|
headers = mapOf(
|
||||||
"Accept" to "application/vnd.github+json",
|
"Accept" to "application/vnd.github+json",
|
||||||
"Authorization" to "token $githubToken"
|
"Authorization" to "token $githubToken"
|
||||||
),
|
),
|
||||||
requestBody = """{"name":"sync data for Cloudstream", "description": "Private repo for cloudstream Account", "private": true}""".toRequestBody(
|
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 {
|
val repoUrl = tryParseJson<repodata>(response.text).let {
|
||||||
setKey(accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
setKey(
|
||||||
|
accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||||
token = githubToken,
|
token = githubToken,
|
||||||
repoUrl = it?.repoUrl ?: run {
|
repoUrl = it?.repoUrl ?: run {
|
||||||
return false
|
return false
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
it.repoUrl
|
it.repoUrl
|
||||||
}
|
}
|
||||||
commitFile(repoUrl, githubToken)
|
commitFile(repoUrl, githubToken)
|
||||||
return true
|
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 {
|
override suspend fun login(data: InAppAuthAPI.LoginData): Boolean {
|
||||||
switchToNewAccount()
|
switchToNewAccount()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue