1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2024-12-26 08:53:12 +01:00

(Misskey 8.22移行)リストの削除と名前の変更

This commit is contained in:
tateisu 2018-09-05 02:12:36 +09:00
parent 36a09004fd
commit e51ed68e0b
3 changed files with 29 additions and 28 deletions

View File

@ -29,7 +29,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -89,10 +89,6 @@ object Action_List {
list : TootList,
bConfirmed : Boolean = false
) {
if(access_info.isMisskey) {
showToast(activity, false, "Misskey has no API to delete list")
return
}
if(! bConfirmed) {
DlgConfirm.openSimple(
@ -107,7 +103,10 @@ object Action_List {
TootTaskRunner(activity).run(access_info, object : TootTask {
override fun background(client : TootApiClient) : TootApiResult? {
return if(access_info.isMisskey) {
TootApiResult("Misskey has no API to delete list")
val params = access_info.putMisskeyApiToken()
.put("listId", list.id)
client.request("/api/users/lists/delete", params.toPostRequestBuilder())
// 204 no content
} else {
client.request("/api/v1/lists/{list.id}", Request.Builder().delete())
}
@ -136,10 +135,6 @@ object Action_List {
access_info : SavedAccount,
item : TootList
) {
if(access_info.isMisskey) {
showToast(activity, false, "Misskey has no API to rename list")
return
}
DlgTextInput.show(
activity,
@ -154,26 +149,32 @@ object Action_List {
TootTaskRunner(activity).run(access_info, object : TootTask {
var list : TootList? = null
override fun background(client : TootApiClient) : TootApiResult? {
if(access_info.isMisskey) {
return TootApiResult("Misskey has no API to rename list")
}
val content = JSONObject()
try {
content.put("title", text)
} catch(ex : Throwable) {
return TootApiResult(ex.withCaption("can't encoding json parameter."))
}
val request_builder = Request.Builder().put(
RequestBody.create(
TootApiClient.MEDIA_TYPE_JSON, content.toString()
val result = if(access_info.isMisskey) {
val params = access_info.putMisskeyApiToken()
.put("listId", item.id)
.put("title", text)
client.request(
"/api/users/lists/update",
params.toPostRequestBuilder()
)
} else {
val content = JSONObject()
try {
content.put("title", text)
} catch(ex : Throwable) {
return TootApiResult(ex.withCaption("can't encoding json parameter."))
}
val request_builder = Request.Builder().put(
RequestBody.create(
TootApiClient.MEDIA_TYPE_JSON, content.toString()
)
)
)
val result =
client.request("/api/v1/lists/${item.id}", request_builder)
}
client.publishApiProgress(activity.getString(R.string.parsing_response))
list = parseItem(

View File

@ -913,7 +913,7 @@ class SavedAccount(
val misskeyApiToken : String?
get() = token_info?.parseString(TootApiClient.KEY_API_KEY_MISSKEY)
fun putMisskeyApiToken(params : JSONObject) : JSONObject {
fun putMisskeyApiToken(params : JSONObject =JSONObject()) : JSONObject {
val apiKey = misskeyApiToken
if(apiKey?.isNotEmpty() == true) params.put("i", apiKey)
return params