(Misskey)通報APIが使えるらしいので試してみる

This commit is contained in:
tateisu 2021-06-02 01:26:19 +09:00
parent 8b9b40c7b0
commit c33cf4797f
2 changed files with 35 additions and 14 deletions

View File

@ -18,6 +18,7 @@ import jp.juggler.subwaytooter.util.openCustomTab
import jp.juggler.util.*
import kotlinx.coroutines.*
import okhttp3.Request
import java.lang.StringBuilder
// ユーザをミュート/ミュート解除する
@ -655,19 +656,38 @@ private fun ActMain.userReport(
}
launchMain {
runApiTask(access_info) { client ->
client.request(
"/api/v1/reports",
JsonObject().apply {
put("account_id", who.id.toString())
put("comment", comment)
put("forward", forward)
if (status != null) {
put("status_ids", jsonArray {
add(status.id.toString())
})
}
}.toPostRequestBuilder()
)
if (access_info.isMisskey) {
client.request(
"/api/users/report-abuse",
access_info.putMisskeyApiToken().apply {
put("userId", who.id.toString())
put(
"comment",
StringBuilder().apply {
status?.let {
append(it.url)
append("\n")
}
append(comment)
}.toString()
)
}.toPostRequestBuilder()
)
} else {
client.request(
"/api/v1/reports",
JsonObject().apply {
put("account_id", who.id.toString())
put("comment", comment)
put("forward", forward)
if (status != null) {
put("status_ids", jsonArray {
add(status.id.toString())
})
}
}.toPostRequestBuilder()
)
}
}?.let { result ->
when (result.jsonObject) {
null -> showToast(true, result.error)

View File

@ -34,7 +34,8 @@ object ReportForm {
val cbForward : CheckBox = view.findViewById(R.id.cbForward)
val tvForwardDesc : TextView = view.findViewById(R.id.tvForwardDesc)
val canForward = ! access_info.matchHost(who)
val canForward = ! access_info.matchHost(who) && !access_info.isMisskey
cbForward.isChecked = false
if(! canForward) {