2018-01-04 19:52:25 +01:00
|
|
|
|
package jp.juggler.subwaytooter.action
|
|
|
|
|
|
2018-11-22 01:07:53 +01:00
|
|
|
|
import android.text.SpannableStringBuilder
|
2021-01-03 06:11:04 +01:00
|
|
|
|
import jp.juggler.emoji.EmojiMap
|
2018-08-30 14:33:22 +02:00
|
|
|
|
import jp.juggler.subwaytooter.*
|
|
|
|
|
import jp.juggler.subwaytooter.api.*
|
2018-10-28 14:08:10 +01:00
|
|
|
|
import jp.juggler.subwaytooter.api.entity.*
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import jp.juggler.subwaytooter.dialog.AccountPicker
|
|
|
|
|
import jp.juggler.subwaytooter.dialog.ActionsDialog
|
|
|
|
|
import jp.juggler.subwaytooter.dialog.DlgConfirm
|
2021-01-03 06:11:04 +01:00
|
|
|
|
import jp.juggler.subwaytooter.dialog.EmojiPicker
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import jp.juggler.subwaytooter.table.AcctColor
|
|
|
|
|
import jp.juggler.subwaytooter.table.SavedAccount
|
2018-12-01 00:02:18 +01:00
|
|
|
|
import jp.juggler.subwaytooter.util.SavedAccountCallback
|
2020-09-08 01:55:15 +02:00
|
|
|
|
import jp.juggler.subwaytooter.util.matchHost
|
2020-09-29 19:44:56 +02:00
|
|
|
|
import jp.juggler.subwaytooter.util.openCustomTab
|
2018-12-02 11:25:00 +01:00
|
|
|
|
import jp.juggler.util.*
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import okhttp3.Request
|
2018-08-30 14:33:22 +02:00
|
|
|
|
import java.util.*
|
2019-12-08 16:46:10 +01:00
|
|
|
|
import kotlin.math.max
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
object Action_Toot {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
private val log = LogCategory("Action_Toot")
|
|
|
|
|
|
|
|
|
|
private val reDetailedStatusTime =
|
|
|
|
|
"""<a\b[^>]*?\bdetailed-status__datetime\b[^>]*href="https://[^/]+/@[^/]+/([^\s?#/"]+)"""
|
|
|
|
|
.asciiPattern()
|
|
|
|
|
|
|
|
|
|
// アカウントを選んでお気に入り
|
|
|
|
|
fun favouriteFromAnotherAccount(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
timeline_account: SavedAccount,
|
|
|
|
|
status: TootStatus?
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (status == null) return
|
|
|
|
|
|
|
|
|
|
AccountPicker.pick(
|
2018-01-13 07:15:52 +01:00
|
|
|
|
activity,
|
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAuto = false,
|
|
|
|
|
message = activity.getString(R.string.account_picker_favourite),
|
2020-09-07 14:20:11 +02:00
|
|
|
|
accountListArg = makeAccountListNonPseudo(activity, timeline_account.apDomain)
|
2018-01-13 07:15:52 +01:00
|
|
|
|
) { action_account ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
favourite(
|
2018-01-10 16:47:35 +01:00
|
|
|
|
activity,
|
|
|
|
|
action_account,
|
|
|
|
|
status,
|
|
|
|
|
calcCrossAccountMode(timeline_account, action_account),
|
2018-04-17 14:41:22 +02:00
|
|
|
|
callback = activity.favourite_complete_callback
|
2018-01-04 19:52:25 +01:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// お気に入りの非同期処理
|
|
|
|
|
fun favourite(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
arg_status: TootStatus,
|
|
|
|
|
nCrossAccountMode: Int,
|
|
|
|
|
callback: () -> Unit,
|
|
|
|
|
bSet: Boolean = true,
|
|
|
|
|
bConfirmed: Boolean = false
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (activity.app_state.isBusyFav(access_info, arg_status)) {
|
|
|
|
|
activity.showToast(false, R.string.wait_previous_operation)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 必要なら確認を出す
|
|
|
|
|
if (!bConfirmed && access_info.isMastodon) {
|
|
|
|
|
DlgConfirm.open(
|
2018-04-17 14:41:22 +02:00
|
|
|
|
activity,
|
|
|
|
|
activity.getString(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
when (bSet) {
|
2018-04-20 12:43:09 +02:00
|
|
|
|
true -> R.string.confirm_favourite_from
|
|
|
|
|
else -> R.string.confirm_unfavourite_from
|
|
|
|
|
},
|
2020-02-01 14:26:57 +01:00
|
|
|
|
AcctColor.getNickname(access_info)
|
2018-04-17 14:41:22 +02:00
|
|
|
|
),
|
|
|
|
|
object : DlgConfirm.Callback {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-04-17 14:41:22 +02:00
|
|
|
|
override fun onOK() {
|
|
|
|
|
favourite(
|
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
arg_status,
|
|
|
|
|
nCrossAccountMode,
|
2018-04-20 12:43:09 +02:00
|
|
|
|
callback,
|
|
|
|
|
bSet = bSet,
|
|
|
|
|
bConfirmed = true
|
2018-04-17 14:41:22 +02:00
|
|
|
|
)
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override var isConfirmEnabled: Boolean
|
|
|
|
|
get() = when (bSet) {
|
2018-04-20 12:43:09 +02:00
|
|
|
|
true -> access_info.confirm_favourite
|
|
|
|
|
else -> access_info.confirm_unfavourite
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-04-20 12:43:09 +02:00
|
|
|
|
}
|
2018-04-17 14:41:22 +02:00
|
|
|
|
set(value) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
when (bSet) {
|
2018-04-20 12:43:09 +02:00
|
|
|
|
true -> access_info.confirm_favourite = value
|
|
|
|
|
else -> access_info.confirm_unfavourite = value
|
|
|
|
|
}
|
2018-04-17 14:41:22 +02:00
|
|
|
|
access_info.saveSetting()
|
|
|
|
|
activity.reloadAccountSetting(access_info)
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-04-17 14:41:22 +02:00
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
activity.app_state.setBusyFav(access_info, arg_status)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
TootTaskRunner(activity, TootTaskRunner.PROGRESS_NONE).run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var new_status: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
|
|
|
|
val target_status = if (nCrossAccountMode == CROSS_ACCOUNT_REMOTE_INSTANCE) {
|
|
|
|
|
|
2019-06-26 08:47:47 +02:00
|
|
|
|
val (result, status) = client.syncStatus(access_info, arg_status)
|
2019-01-16 16:27:37 +01:00
|
|
|
|
status ?: return result
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (status.favourited) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return TootApiResult(activity.getString(R.string.already_favourited))
|
|
|
|
|
}
|
2019-01-16 16:27:37 +01:00
|
|
|
|
status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
2019-01-16 16:27:37 +01:00
|
|
|
|
arg_status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return if (access_info.isMisskey) {
|
2019-01-16 16:27:37 +01:00
|
|
|
|
client.request(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (bSet) {
|
2018-08-20 19:37:42 +02:00
|
|
|
|
"/api/notes/favorites/create"
|
|
|
|
|
} else {
|
|
|
|
|
"/api/notes/favorites/delete"
|
2019-01-16 16:27:37 +01:00
|
|
|
|
},
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", target_status.id.toString())
|
|
|
|
|
}
|
2019-01-16 16:27:37 +01:00
|
|
|
|
.toPostRequestBuilder()
|
2019-06-26 08:47:47 +02:00
|
|
|
|
)?.also { result ->
|
2019-01-16 16:27:37 +01:00
|
|
|
|
// 正常レスポンスは 204 no content
|
|
|
|
|
// 既にお気に入り済みならエラー文字列に'already favorited' が返る
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (result.response?.code == 204
|
2019-01-16 16:27:37 +01:00
|
|
|
|
|| result.error?.contains("already favorited") == true
|
|
|
|
|
|| result.error?.contains("already not favorited") == true
|
|
|
|
|
) {
|
|
|
|
|
// 成功した
|
2019-06-26 08:47:47 +02:00
|
|
|
|
new_status = target_status.apply {
|
2019-01-16 16:27:37 +01:00
|
|
|
|
favourited = bSet
|
|
|
|
|
}
|
2018-08-20 02:07:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-20 19:37:42 +02:00
|
|
|
|
} else {
|
2019-01-16 16:27:37 +01:00
|
|
|
|
client.request(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
"/api/v1/statuses/${target_status.id}/${if (bSet) "favourite" else "unfavourite"}",
|
2019-08-24 05:35:22 +02:00
|
|
|
|
"".toFormRequestBody().toPost()
|
2019-06-26 08:47:47 +02:00
|
|
|
|
)?.also { result ->
|
2019-01-16 16:27:37 +01:00
|
|
|
|
new_status = TootParser(activity, access_info).status(result.jsonObject)
|
|
|
|
|
}
|
2018-08-20 02:07:55 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
2020-12-21 03:13:03 +01:00
|
|
|
|
|
|
|
|
|
activity.app_state.resetBusyFav(access_info, arg_status)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val new_status = this.new_status
|
|
|
|
|
when {
|
|
|
|
|
result == null -> {
|
|
|
|
|
} // cancelled.
|
|
|
|
|
new_status != null -> {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val old_count = arg_status.favourites_count
|
|
|
|
|
val new_count = new_status.favourites_count
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (old_count != null && new_count != null) {
|
|
|
|
|
if (access_info.isMisskey) {
|
2018-08-20 02:07:55 +02:00
|
|
|
|
new_status.favourited = bSet
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (bSet && new_status.favourited && new_count <= old_count) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// 星をつけたのにカウントが上がらないのは違和感あるので、表示をいじる
|
2018-08-20 19:37:42 +02:00
|
|
|
|
new_status.favourites_count = old_count + 1L
|
2021-01-03 06:11:04 +01:00
|
|
|
|
} else if (!bSet && !new_status.favourited && new_count >= old_count) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// 星を外したのにカウントが下がらないのは違和感あるので、表示をいじる
|
|
|
|
|
// 0未満にはならない
|
2018-08-20 19:37:42 +02:00
|
|
|
|
new_status.favourites_count =
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (old_count < 1L) 0L else old_count - 1L
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
for (column in activity.app_state.columnList) {
|
2020-09-07 14:20:11 +02:00
|
|
|
|
column.findStatus(
|
|
|
|
|
access_info.apDomain,
|
|
|
|
|
new_status.id
|
|
|
|
|
) { account, status ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-20 17:59:38 +01:00
|
|
|
|
// 同タンス別アカウントでもカウントは変化する
|
|
|
|
|
status.favourites_count = new_status.favourites_count
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-08-20 02:07:55 +02:00
|
|
|
|
// 同アカウントならfav状態を変化させる
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (access_info == account) {
|
2018-01-20 17:59:38 +01:00
|
|
|
|
status.favourited = new_status.favourited
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-20 17:59:38 +01:00
|
|
|
|
true
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2020-09-29 19:44:56 +02:00
|
|
|
|
else -> activity.showToast(true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
// 結果に関わらず、更新中状態から復帰させる
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// ファボ表示を更新中にする
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// アカウントを選んでお気に入り
|
|
|
|
|
fun bookmarkFromAnotherAccount(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
timeline_account: SavedAccount,
|
|
|
|
|
status: TootStatus?
|
2019-11-14 01:51:17 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
status ?: return
|
|
|
|
|
|
|
|
|
|
AccountPicker.pick(
|
2019-11-14 01:51:17 +01:00
|
|
|
|
activity,
|
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAuto = false,
|
|
|
|
|
message = activity.getString(R.string.account_picker_bookmark),
|
2020-09-07 14:20:11 +02:00
|
|
|
|
accountListArg = makeAccountListNonPseudo(activity, timeline_account.apDomain)
|
2019-11-14 01:51:17 +01:00
|
|
|
|
) { action_account ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
bookmark(
|
2019-11-14 01:51:17 +01:00
|
|
|
|
activity,
|
|
|
|
|
action_account,
|
|
|
|
|
status,
|
|
|
|
|
calcCrossAccountMode(timeline_account, action_account),
|
|
|
|
|
callback = activity.bookmark_complete_callback
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// お気に入りの非同期処理
|
|
|
|
|
fun bookmark(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
arg_status: TootStatus,
|
|
|
|
|
nCrossAccountMode: Int,
|
|
|
|
|
callback: () -> Unit,
|
|
|
|
|
bSet: Boolean = true,
|
|
|
|
|
bConfirmed: Boolean = false
|
2019-11-14 01:51:17 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (activity.app_state.isBusyFav(access_info, arg_status)) {
|
|
|
|
|
activity.showToast(false, R.string.wait_previous_operation)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (access_info.isMisskey) {
|
|
|
|
|
activity.showToast(false, R.string.misskey_account_not_supported)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 必要なら確認を出す
|
|
|
|
|
// ブックマークは解除する時だけ確認する
|
|
|
|
|
if (!bConfirmed && !bSet) {
|
|
|
|
|
DlgConfirm.openSimple(
|
2019-11-14 01:51:17 +01:00
|
|
|
|
activity,
|
|
|
|
|
activity.getString(
|
2019-11-16 12:30:29 +01:00
|
|
|
|
R.string.confirm_unbookmark_from,
|
2020-02-01 14:26:57 +01:00
|
|
|
|
AcctColor.getNickname(access_info)
|
2019-11-14 01:51:17 +01:00
|
|
|
|
)
|
2019-12-08 16:54:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
bookmark(
|
2019-11-14 01:51:17 +01:00
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
arg_status,
|
|
|
|
|
nCrossAccountMode,
|
|
|
|
|
callback,
|
|
|
|
|
bSet = bSet,
|
|
|
|
|
bConfirmed = true
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
activity.app_state.setBusyBookmark(access_info, arg_status)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
TootTaskRunner(activity, TootTaskRunner.PROGRESS_NONE).run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var new_status: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
|
|
|
|
val target_status = if (nCrossAccountMode == CROSS_ACCOUNT_REMOTE_INSTANCE) {
|
2019-11-14 01:51:17 +01:00
|
|
|
|
val (result, status) = client.syncStatus(access_info, arg_status)
|
|
|
|
|
status ?: return result
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (status.bookmarked) {
|
2019-11-14 01:51:17 +01:00
|
|
|
|
return TootApiResult(activity.getString(R.string.already_bookmarked))
|
|
|
|
|
}
|
|
|
|
|
status
|
|
|
|
|
} else {
|
|
|
|
|
arg_status
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-11-14 01:51:17 +01:00
|
|
|
|
return client.request(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
"/api/v1/statuses/${target_status.id}/${if (bSet) "bookmark" else "unbookmark"}",
|
2019-11-14 01:51:17 +01:00
|
|
|
|
"".toFormRequestBody().toPost()
|
|
|
|
|
)?.also { result ->
|
|
|
|
|
new_status = TootParser(activity, access_info).status(result.jsonObject)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
|
2020-12-21 03:13:03 +01:00
|
|
|
|
activity.app_state.resetBusyBookmark(access_info, arg_status)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-11-14 01:51:17 +01:00
|
|
|
|
val new_status = this.new_status
|
|
|
|
|
when {
|
|
|
|
|
result == null -> {
|
|
|
|
|
} // cancelled.
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-11-14 01:51:17 +01:00
|
|
|
|
new_status != null -> {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
for (column in activity.app_state.columnList) {
|
2020-09-07 14:20:11 +02:00
|
|
|
|
column.findStatus(
|
|
|
|
|
access_info.apDomain,
|
|
|
|
|
new_status.id
|
|
|
|
|
) { account, status ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-11-14 01:51:17 +01:00
|
|
|
|
// 同アカウントならブックマーク状態を伝播する
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (access_info == account) {
|
2019-11-14 01:51:17 +01:00
|
|
|
|
status.bookmarked = new_status.bookmarked
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-11-14 01:51:17 +01:00
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback()
|
2019-11-14 01:51:17 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2020-09-29 19:44:56 +02:00
|
|
|
|
else -> activity.showToast(true, result.error)
|
2019-11-14 01:51:17 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-11-14 01:51:17 +01:00
|
|
|
|
// 結果に関わらず、更新中状態から復帰させる
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// ファボ表示を更新中にする
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun boostFromAnotherAccount(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
timeline_account: SavedAccount,
|
|
|
|
|
status: TootStatus?
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
status ?: return
|
|
|
|
|
|
|
|
|
|
val status_owner = timeline_account.getFullAcct(status.account)
|
|
|
|
|
|
|
|
|
|
val isPrivateToot = timeline_account.isMastodon &&
|
|
|
|
|
status.visibility == TootVisibility.PrivateFollowers
|
|
|
|
|
|
|
|
|
|
if (isPrivateToot) {
|
|
|
|
|
val list = ArrayList<SavedAccount>()
|
|
|
|
|
for (a in SavedAccount.loadAccountList(activity)) {
|
|
|
|
|
if (a.acct == status_owner) list.add(a)
|
|
|
|
|
}
|
|
|
|
|
if (list.isEmpty()) {
|
|
|
|
|
activity.showToast(false, R.string.boost_private_toot_not_allowed)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
AccountPicker.pick(
|
2018-03-21 06:18:19 +01:00
|
|
|
|
activity,
|
2018-05-08 07:59:28 +02:00
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAuto = false,
|
|
|
|
|
message = activity.getString(R.string.account_picker_boost),
|
|
|
|
|
accountListArg = list
|
|
|
|
|
) { action_account ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
boost(
|
2018-05-08 07:59:28 +02:00
|
|
|
|
activity,
|
|
|
|
|
action_account,
|
|
|
|
|
status,
|
|
|
|
|
status_owner,
|
|
|
|
|
calcCrossAccountMode(timeline_account, action_account),
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback = activity.boost_complete_callback
|
2018-05-08 07:59:28 +02:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
AccountPicker.pick(
|
2018-05-08 07:59:28 +02:00
|
|
|
|
activity,
|
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAuto = false,
|
|
|
|
|
message = activity.getString(R.string.account_picker_boost),
|
2020-09-07 14:20:11 +02:00
|
|
|
|
accountListArg = makeAccountListNonPseudo(activity, timeline_account.apDomain)
|
2018-05-08 07:59:28 +02:00
|
|
|
|
) { action_account ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
boost(
|
2018-05-08 07:59:28 +02:00
|
|
|
|
activity,
|
|
|
|
|
action_account,
|
|
|
|
|
status,
|
|
|
|
|
status_owner,
|
|
|
|
|
calcCrossAccountMode(timeline_account, action_account),
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback = activity.boost_complete_callback
|
2018-05-08 07:59:28 +02:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun boost(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
arg_status: TootStatus,
|
|
|
|
|
status_owner: Acct,
|
|
|
|
|
nCrossAccountMode: Int,
|
|
|
|
|
bSet: Boolean = true,
|
|
|
|
|
bConfirmed: Boolean = false,
|
|
|
|
|
visibility: TootVisibility? = null,
|
|
|
|
|
callback: () -> Unit
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// アカウントからステータスにブースト操作を行っているなら、何もしない
|
|
|
|
|
if (activity.app_state.isBusyBoost(access_info, arg_status)) {
|
|
|
|
|
activity.showToast(false, R.string.wait_previous_operation)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mastodonは非公開トゥートをブーストできるのは本人だけ
|
2021-02-10 09:08:00 +01:00
|
|
|
|
val isPrivateToot = access_info.isMastodon &&
|
|
|
|
|
arg_status.visibility == TootVisibility.PrivateFollowers
|
|
|
|
|
|
|
|
|
|
if( isPrivateToot && access_info.acct != status_owner) {
|
|
|
|
|
activity.showToast(false, R.string.boost_private_toot_not_allowed)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// DMとかのブーストはAPI側がエラーを出すだろう?
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// 必要なら確認を出す
|
|
|
|
|
if (!bConfirmed) {
|
|
|
|
|
DlgConfirm.open(
|
2018-01-04 19:52:25 +01:00
|
|
|
|
activity,
|
2018-03-21 06:18:19 +01:00
|
|
|
|
activity.getString(
|
2018-08-20 19:37:42 +02:00
|
|
|
|
when {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
!bSet -> R.string.confirm_unboost_from
|
2018-05-08 07:59:28 +02:00
|
|
|
|
isPrivateToot -> R.string.confirm_boost_private_from
|
2019-04-04 05:13:15 +02:00
|
|
|
|
visibility == TootVisibility.PrivateFollowers -> R.string.confirm_private_boost_from
|
2018-08-20 19:37:42 +02:00
|
|
|
|
else -> R.string.confirm_boost_from
|
2018-04-20 12:43:09 +02:00
|
|
|
|
},
|
2020-02-01 14:26:57 +01:00
|
|
|
|
AcctColor.getNickname(access_info)
|
2018-03-21 06:18:19 +01:00
|
|
|
|
),
|
2018-01-04 19:52:25 +01:00
|
|
|
|
object : DlgConfirm.Callback {
|
|
|
|
|
override fun onOK() {
|
2018-03-21 06:18:19 +01:00
|
|
|
|
boost(
|
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
arg_status,
|
2020-02-02 15:19:57 +01:00
|
|
|
|
status_owner,
|
2018-03-21 06:18:19 +01:00
|
|
|
|
nCrossAccountMode,
|
2018-04-20 12:43:09 +02:00
|
|
|
|
bSet = bSet,
|
2019-04-04 05:13:15 +02:00
|
|
|
|
bConfirmed = true,
|
2020-09-29 19:44:56 +02:00
|
|
|
|
visibility = visibility,
|
|
|
|
|
callback = callback,
|
2018-03-21 06:18:19 +01:00
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override var isConfirmEnabled: Boolean
|
|
|
|
|
get() = when (bSet) {
|
2018-04-20 12:43:09 +02:00
|
|
|
|
true -> access_info.confirm_boost
|
|
|
|
|
else -> access_info.confirm_unboost
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
set(value) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
when (bSet) {
|
2018-04-20 12:43:09 +02:00
|
|
|
|
true -> access_info.confirm_boost = value
|
|
|
|
|
else -> access_info.confirm_unboost = value
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
access_info.saveSetting()
|
|
|
|
|
activity.reloadAccountSetting(access_info)
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activity.app_state.setBusyBoost(access_info, arg_status)
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity, TootTaskRunner.PROGRESS_NONE).run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var new_status: TootStatus? = null
|
|
|
|
|
var unrenoteId: EntityId? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val parser = TootParser(activity, access_info)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
val target_status = if (nCrossAccountMode == CROSS_ACCOUNT_REMOTE_INSTANCE) {
|
2019-06-26 08:47:47 +02:00
|
|
|
|
val (result, status) = client.syncStatus(access_info, arg_status)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (status == null) return result
|
|
|
|
|
if (status.reblogged) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return TootApiResult(activity.getString(R.string.already_boosted))
|
|
|
|
|
}
|
2019-01-16 16:27:37 +01:00
|
|
|
|
status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
|
|
|
|
// 既に自タンスのステータスがある
|
2019-01-16 16:27:37 +01:00
|
|
|
|
arg_status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
if (access_info.isMisskey) {
|
|
|
|
|
return if (!bSet) {
|
2019-12-08 16:46:10 +01:00
|
|
|
|
val myRenoteId = target_status.myRenoteId
|
|
|
|
|
?: return TootApiResult("missing renote id.")
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-12-08 16:46:10 +01:00
|
|
|
|
client.request(
|
|
|
|
|
"/api/notes/delete",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", myRenoteId.toString())
|
|
|
|
|
put("renoteId", target_status.id.toString())
|
|
|
|
|
}
|
2019-12-08 16:46:10 +01:00
|
|
|
|
.toPostRequestBuilder()
|
|
|
|
|
)
|
2019-12-08 16:54:25 +01:00
|
|
|
|
?.also {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (it.response?.code == 204)
|
2019-12-08 16:46:10 +01:00
|
|
|
|
unrenoteId = myRenoteId
|
|
|
|
|
}
|
2018-08-20 19:37:42 +02:00
|
|
|
|
} else {
|
2019-12-08 16:46:10 +01:00
|
|
|
|
client.request(
|
2019-12-08 16:54:25 +01:00
|
|
|
|
"/api/notes/create",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("renoteId", target_status.id.toString())
|
|
|
|
|
}
|
2019-12-08 16:54:25 +01:00
|
|
|
|
.toPostRequestBuilder()
|
|
|
|
|
)
|
|
|
|
|
?.also { result ->
|
2019-12-08 16:46:10 +01:00
|
|
|
|
val jsonObject = result.jsonObject
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (jsonObject != null) {
|
2019-12-08 16:46:10 +01:00
|
|
|
|
val outerStatus = parser.status(
|
2020-01-08 04:23:45 +01:00
|
|
|
|
jsonObject.jsonObject("createdNote")
|
2019-12-08 16:46:10 +01:00
|
|
|
|
?: jsonObject
|
|
|
|
|
)
|
|
|
|
|
val innerStatus = outerStatus?.reblog ?: outerStatus
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (outerStatus != null && innerStatus != null && outerStatus != innerStatus) {
|
2019-12-08 16:46:10 +01:00
|
|
|
|
innerStatus.myRenoteId = outerStatus.id
|
|
|
|
|
innerStatus.reblogged = true
|
|
|
|
|
}
|
|
|
|
|
// renoteそのものではなくrenoteされた元noteが欲しい
|
|
|
|
|
this.new_status = innerStatus
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-20 02:07:55 +02:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-08-20 19:37:42 +02:00
|
|
|
|
} else {
|
2020-01-07 09:03:32 +01:00
|
|
|
|
val b = JsonObject().apply {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (visibility != null) put("visibility", visibility.strMastodon)
|
2019-04-04 05:13:15 +02:00
|
|
|
|
}.toPostRequestBuilder()
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-16 16:27:37 +01:00
|
|
|
|
val result = client.request(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
"/api/v1/statuses/${target_status.id}/${if (bSet) "reblog" else "unreblog"}",
|
2019-04-04 05:13:15 +02:00
|
|
|
|
b
|
2018-08-20 02:07:55 +02:00
|
|
|
|
)
|
2018-12-02 10:35:04 +01:00
|
|
|
|
// reblogはreblogを表すStatusを返す
|
|
|
|
|
// unreblogはreblogしたStatusを返す
|
|
|
|
|
val s = parser.status(result?.jsonObject)
|
|
|
|
|
this.new_status = s?.reblog ?: s
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-08-20 02:07:55 +02:00
|
|
|
|
return result
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
2020-12-21 03:13:03 +01:00
|
|
|
|
activity.app_state.resetBusyBoost(access_info, arg_status)
|
|
|
|
|
|
2019-12-08 16:46:10 +01:00
|
|
|
|
val unrenoteId = this.unrenoteId
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val new_status = this.new_status
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
when {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-09-23 19:14:50 +02:00
|
|
|
|
// cancelled.
|
2018-01-04 19:52:25 +01:00
|
|
|
|
result == null -> {
|
2019-09-23 19:14:50 +02:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-12-08 16:46:10 +01:00
|
|
|
|
// Misskeyでunrenoteに成功した
|
2019-12-08 16:54:25 +01:00
|
|
|
|
unrenoteId != null -> {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-12-08 16:46:10 +01:00
|
|
|
|
// 星を外したのにカウントが下がらないのは違和感あるので、表示をいじる
|
|
|
|
|
// 0未満にはならない
|
2019-12-08 16:54:25 +01:00
|
|
|
|
val count = max(0, (arg_status.reblogs_count ?: 1) - 1)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
for (column in activity.app_state.columnList) {
|
2020-09-07 14:20:11 +02:00
|
|
|
|
column.findStatus(
|
|
|
|
|
access_info.apDomain,
|
|
|
|
|
arg_status.id
|
|
|
|
|
) { account, status ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-12-08 16:46:10 +01:00
|
|
|
|
// 同タンス別アカウントでもカウントは変化する
|
|
|
|
|
status.reblogs_count = count
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-12-08 16:46:10 +01:00
|
|
|
|
// 同アカウントならreblogged状態を変化させる
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (access_info == account && status.myRenoteId == unrenoteId) {
|
2019-12-08 16:46:10 +01:00
|
|
|
|
status.myRenoteId = null
|
|
|
|
|
status.reblogged = false
|
|
|
|
|
}
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback()
|
2019-12-08 16:46:10 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
new_status != null -> {
|
|
|
|
|
// カウント数は遅延があるみたいなので、恣意的に表示を変更する
|
|
|
|
|
// ブーストカウント数を加工する
|
|
|
|
|
val old_count = arg_status.reblogs_count
|
|
|
|
|
val new_count = new_status.reblogs_count
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (old_count != null && new_count != null) {
|
|
|
|
|
if (bSet && new_status.reblogged && new_count <= old_count) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// 星をつけたのにカウントが上がらないのは違和感あるので、表示をいじる
|
|
|
|
|
new_status.reblogs_count = old_count + 1
|
2021-01-03 06:11:04 +01:00
|
|
|
|
} else if (!bSet && !new_status.reblogged && new_count >= old_count) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// 星を外したのにカウントが下がらないのは違和感あるので、表示をいじる
|
|
|
|
|
// 0未満にはならない
|
2021-01-03 06:11:04 +01:00
|
|
|
|
new_status.reblogs_count = if (old_count < 1) 0 else old_count - 1
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
for (column in activity.app_state.columnList) {
|
2020-09-07 14:20:11 +02:00
|
|
|
|
column.findStatus(
|
|
|
|
|
access_info.apDomain,
|
|
|
|
|
new_status.id
|
|
|
|
|
) { account, status ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-20 17:59:38 +01:00
|
|
|
|
// 同タンス別アカウントでもカウントは変化する
|
|
|
|
|
status.reblogs_count = new_status.reblogs_count
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
if (access_info == account) {
|
|
|
|
|
|
2018-01-20 17:59:38 +01:00
|
|
|
|
// 同アカウントならreblog状態を変化させる
|
2019-12-08 16:54:25 +01:00
|
|
|
|
when {
|
2019-12-09 09:05:13 +01:00
|
|
|
|
access_info.isMastodon ->
|
2019-12-08 16:54:25 +01:00
|
|
|
|
status.reblogged = new_status.reblogged
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-12-08 16:54:25 +01:00
|
|
|
|
bSet && status.myRenoteId == null -> {
|
2019-12-08 16:46:10 +01:00
|
|
|
|
status.myRenoteId = new_status.myRenoteId
|
|
|
|
|
status.reblogged = true
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-08 16:54:25 +01:00
|
|
|
|
// Misskey のunrenote時はここを通らない
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-01-20 17:59:38 +01:00
|
|
|
|
true
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2020-09-29 19:44:56 +02:00
|
|
|
|
else -> activity.showToast(true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// 結果に関わらず、更新中状態から復帰させる
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// ブースト表示を更新中にする
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
|
|
|
|
// misskeyは非公開トゥートをブーストできないっぽい
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun delete(activity: ActMain, access_info: SavedAccount, status_id: EntityId) {
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity).run(access_info, object : TootTask {
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
return if (access_info.isMisskey) {
|
2019-12-09 09:05:13 +01:00
|
|
|
|
client.request(
|
|
|
|
|
"/api/notes/delete",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", status_id)
|
|
|
|
|
}
|
2019-12-09 09:05:13 +01:00
|
|
|
|
.toPostRequestBuilder()
|
|
|
|
|
)
|
2018-11-02 01:39:32 +01:00
|
|
|
|
// 204 no content
|
|
|
|
|
} else {
|
2019-12-09 09:05:13 +01:00
|
|
|
|
client.request(
|
|
|
|
|
"/api/v1/statuses/$status_id",
|
|
|
|
|
Request.Builder().delete()
|
|
|
|
|
)
|
2018-11-02 01:39:32 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
if (result == null) return // cancelled.
|
|
|
|
|
|
|
|
|
|
if (result.jsonObject != null) {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(false, R.string.delete_succeeded)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
for (column in activity.app_state.columnList) {
|
2020-09-07 14:20:11 +02:00
|
|
|
|
column.onStatusRemoved(access_info.apDomain, status_id)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(false, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// open conversation
|
|
|
|
|
|
|
|
|
|
internal fun clearConversationUnread(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
conversationSummary: TootConversationSummary?
|
2018-11-02 01:39:32 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
conversationSummary ?: return
|
|
|
|
|
TootTaskRunner(activity, progress_style = TootTaskRunner.PROGRESS_NONE)
|
|
|
|
|
.run(access_info, object : TootTask {
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
2018-10-28 14:08:10 +01:00
|
|
|
|
return client.request(
|
2018-12-02 10:35:04 +01:00
|
|
|
|
"/api/v1/conversations/${conversationSummary.id}/read",
|
2019-08-24 05:35:22 +02:00
|
|
|
|
"".toFormRequestBody().toPost()
|
2018-10-28 14:08:10 +01:00
|
|
|
|
)
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
2018-10-28 14:08:10 +01:00
|
|
|
|
// 何もしない
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ローカルかリモートか判断する
|
|
|
|
|
fun conversation(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
pos: Int,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
status: TootStatus
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (access_info.isNA || !access_info.matchHost(status.readerApDomain)) {
|
|
|
|
|
conversationOtherInstance(activity, pos, status)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
conversationLocal(activity, pos, access_info, status.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ローカルから見える会話の流れを表示する
|
|
|
|
|
fun conversationLocal(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
pos: Int,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
status_id: EntityId
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
activity.addColumn(pos, access_info, ColumnType.CONVERSATION, status_id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// リモートかもしれない会話の流れを表示する
|
|
|
|
|
fun conversationOtherInstance(
|
|
|
|
|
activity: ActMain, pos: Int, status: TootStatus?
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (status == null) return
|
|
|
|
|
val url = status.url
|
|
|
|
|
|
|
|
|
|
if (url == null || url.isEmpty()) {
|
|
|
|
|
// URLが不明なトゥートというのはreblogの外側のアレ
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
when {
|
|
|
|
|
|
|
|
|
|
// 検索サービスではステータスTLをどのタンスから読んだのか分からない
|
|
|
|
|
status.readerApDomain == null ->
|
|
|
|
|
conversationOtherInstance(
|
2020-09-07 14:20:11 +02:00
|
|
|
|
activity, pos, url, TootStatus.validStatusId(status.id)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
?: TootStatus.findStatusIdFromUri(
|
|
|
|
|
status.uri,
|
|
|
|
|
status.url
|
|
|
|
|
)
|
2018-08-25 10:05:50 +02:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// TLアカウントのホストとトゥートのアカウントのホストが同じ
|
|
|
|
|
status.originalApDomain == status.readerApDomain ->
|
|
|
|
|
conversationOtherInstance(
|
2020-09-07 14:20:11 +02:00
|
|
|
|
activity, pos, url, TootStatus.validStatusId(status.id)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
?: TootStatus.findStatusIdFromUri(
|
2018-08-25 10:05:50 +02:00
|
|
|
|
status.uri,
|
2019-01-28 19:02:09 +01:00
|
|
|
|
status.url
|
2021-01-03 06:11:04 +01:00
|
|
|
|
)
|
2018-03-21 06:18:19 +01:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
// トゥートを取得したタンスと投稿元タンスが異なる場合
|
|
|
|
|
// status.id はトゥートを取得したタンスでのIDである
|
|
|
|
|
// 投稿元タンスでのIDはuriやURLから調べる
|
|
|
|
|
// pleromaではIDがuuidなので失敗する(その時はURLを検索してIDを見つける)
|
|
|
|
|
conversationOtherInstance(
|
|
|
|
|
activity, pos, url, TootStatus.findStatusIdFromUri(
|
|
|
|
|
status.uri,
|
|
|
|
|
status.url
|
|
|
|
|
), status.readerApDomain, TootStatus.validStatusId(status.id)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// アプリ外部からURLを渡された場合に呼ばれる
|
|
|
|
|
fun conversationOtherInstance(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
pos: Int,
|
|
|
|
|
url: String,
|
|
|
|
|
status_id_original: EntityId? = null,
|
|
|
|
|
host_access: Host? = null,
|
|
|
|
|
status_id_access: EntityId? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
val dialog = ActionsDialog()
|
|
|
|
|
|
|
|
|
|
val host_original = Host.parse(url.toUri().authority ?: "")
|
|
|
|
|
|
|
|
|
|
// 選択肢:ブラウザで表示する
|
|
|
|
|
dialog.addAction(activity.getString(R.string.open_web_on_host, host_original.pretty))
|
|
|
|
|
{ activity.openCustomTab(url) }
|
|
|
|
|
|
|
|
|
|
// トゥートの投稿元タンスにあるアカウント
|
|
|
|
|
val local_account_list = ArrayList<SavedAccount>()
|
|
|
|
|
|
|
|
|
|
// TLを読んだタンスにあるアカウント
|
|
|
|
|
val access_account_list = ArrayList<SavedAccount>()
|
|
|
|
|
|
|
|
|
|
// その他のタンスにあるアカウント
|
|
|
|
|
val other_account_list = ArrayList<SavedAccount>()
|
|
|
|
|
|
|
|
|
|
for (a in SavedAccount.loadAccountList(activity)) {
|
|
|
|
|
|
|
|
|
|
// 疑似アカウントは後でまとめて処理する
|
|
|
|
|
if (a.isPseudo) continue
|
|
|
|
|
|
|
|
|
|
if (status_id_original != null && a.matchHost(host_original)) {
|
|
|
|
|
// アクセス情報+ステータスID でアクセスできるなら
|
|
|
|
|
// 同タンスのアカウントならステータスIDの変換なしに表示できる
|
|
|
|
|
local_account_list.add(a)
|
|
|
|
|
} else if (status_id_access != null && a.matchHost(host_access)) {
|
|
|
|
|
// 既に変換済みのステータスIDがあるなら、そのアカウントでもステータスIDの変換は必要ない
|
|
|
|
|
access_account_list.add(a)
|
|
|
|
|
} else {
|
|
|
|
|
// 別タンスでも実アカウントなら検索APIでステータスIDを変換できる
|
|
|
|
|
other_account_list.add(a)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 同タンスのアカウントがないなら、疑似アカウントで開く選択肢
|
|
|
|
|
if (local_account_list.isEmpty()) {
|
|
|
|
|
if (status_id_original != null) {
|
|
|
|
|
dialog.addAction(
|
2020-02-02 15:19:57 +01:00
|
|
|
|
activity.getString(R.string.open_in_pseudo_account, "?@${host_original.pretty}")
|
2018-03-21 06:18:19 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
addPseudoAccount(activity, host_original) { sa ->
|
|
|
|
|
conversationLocal(activity, pos, sa, status_id_original)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dialog.addAction(
|
2020-02-02 15:19:57 +01:00
|
|
|
|
activity.getString(R.string.open_in_pseudo_account, "?@${host_original.pretty}")
|
2018-03-21 06:18:19 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
addPseudoAccount(activity, host_original) { sa ->
|
|
|
|
|
conversationRemote(activity, pos, sa, url)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ローカルアカウント
|
|
|
|
|
if (status_id_original != null) {
|
|
|
|
|
SavedAccount.sort(local_account_list)
|
|
|
|
|
for (a in local_account_list) {
|
|
|
|
|
dialog.addAction(
|
2018-08-18 12:58:14 +02:00
|
|
|
|
AcctColor.getStringWithNickname(
|
|
|
|
|
activity,
|
|
|
|
|
R.string.open_in_account,
|
2020-02-02 15:19:57 +01:00
|
|
|
|
a.acct
|
2018-08-18 12:58:14 +02:00
|
|
|
|
)
|
|
|
|
|
) { conversationLocal(activity, pos, a, status_id_original) }
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// アクセスしたアカウント
|
|
|
|
|
if (status_id_access != null) {
|
|
|
|
|
SavedAccount.sort(access_account_list)
|
|
|
|
|
for (a in access_account_list) {
|
|
|
|
|
dialog.addAction(
|
2018-08-18 12:58:14 +02:00
|
|
|
|
AcctColor.getStringWithNickname(
|
|
|
|
|
activity,
|
|
|
|
|
R.string.open_in_account,
|
2020-02-02 15:19:57 +01:00
|
|
|
|
a.acct
|
2018-08-18 12:58:14 +02:00
|
|
|
|
)
|
|
|
|
|
) { conversationLocal(activity, pos, a, status_id_access) }
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// その他の実アカウント
|
|
|
|
|
SavedAccount.sort(other_account_list)
|
|
|
|
|
for (a in other_account_list) {
|
|
|
|
|
dialog.addAction(
|
2018-03-21 06:18:19 +01:00
|
|
|
|
AcctColor.getStringWithNickname(
|
|
|
|
|
activity,
|
|
|
|
|
R.string.open_in_account,
|
2020-02-02 15:19:57 +01:00
|
|
|
|
a.acct
|
2018-03-21 06:18:19 +01:00
|
|
|
|
)
|
|
|
|
|
) { conversationRemote(activity, pos, a, url) }
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialog.show(activity, activity.getString(R.string.open_status_from))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun conversationRemote(
|
|
|
|
|
activity: ActMain, pos: Int, access_info: SavedAccount, remote_status_url: String
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
TootTaskRunner(activity)
|
|
|
|
|
.progressPrefix(activity.getString(R.string.progress_synchronize_toot))
|
|
|
|
|
.run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var local_status_id: EntityId? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? =
|
|
|
|
|
if (access_info.isPseudo) {
|
2018-01-11 10:31:25 +01:00
|
|
|
|
// 疑似アカウントではURLからIDを取得するのにHTMLと正規表現を使う
|
2019-01-16 16:27:37 +01:00
|
|
|
|
val result = client.getHttp(remote_status_url)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val string = result?.string
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (string != null) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
try {
|
|
|
|
|
val m = reDetailedStatusTime.matcher(string)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (m.find()) {
|
|
|
|
|
local_status_id = EntityId(m.groupEx(1)!!)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
} catch (ex: Throwable) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
log.e(ex, "openStatusRemote: can't parse status id from HTML data.")
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
if (result.error == null && local_status_id == null) {
|
2019-01-16 16:27:37 +01:00
|
|
|
|
result.setError(activity.getString(R.string.status_id_conversion_failed))
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-16 16:27:37 +01:00
|
|
|
|
result
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
2019-06-26 08:47:47 +02:00
|
|
|
|
val (result, status) = client.syncStatus(access_info, remote_status_url)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (status != null) {
|
2019-01-16 16:27:37 +01:00
|
|
|
|
local_status_id = status.id
|
|
|
|
|
log.d("status id conversion %s => %s", remote_status_url, status.id)
|
|
|
|
|
}
|
|
|
|
|
result
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
if (result == null) return // cancelled.
|
|
|
|
|
|
2018-08-18 12:58:14 +02:00
|
|
|
|
val local_status_id = this.local_status_id
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (local_status_id != null) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
conversationLocal(activity, pos, access_info, local_status_id)
|
|
|
|
|
} else {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// tootsearch APIは投稿の返信元を示すreplyの情報がない。
|
|
|
|
|
// in_reply_to_idを参照するしかない
|
|
|
|
|
// ところがtootsearchでは投稿をどのタンスから読んだか分からないので、IDは全面的に信用できない。
|
|
|
|
|
// 疑似ではないアカウントを選んだ後に表示中の投稿を検索APIで調べて、そのリプライのIDを取得しなおす
|
|
|
|
|
fun showReplyTootsearch(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
pos: Int,
|
|
|
|
|
statusArg: TootStatus?
|
2019-09-23 19:02:01 +02:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
statusArg ?: return
|
|
|
|
|
|
|
|
|
|
// step2: 選択したアカウントで投稿を検索して返信元の投稿のIDを調べる
|
|
|
|
|
fun step2(a: SavedAccount) = TootTaskRunner(activity).run(a, object : TootTask {
|
|
|
|
|
var tmp: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
2019-09-23 19:08:38 +02:00
|
|
|
|
val (result, status) = client.syncStatus(a, statusArg)
|
2019-09-23 19:02:01 +02:00
|
|
|
|
this.tmp = status
|
|
|
|
|
return result
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
2019-09-23 19:08:38 +02:00
|
|
|
|
result ?: return
|
2019-09-23 19:02:01 +02:00
|
|
|
|
val status = tmp
|
|
|
|
|
val replyId = status?.in_reply_to_id
|
|
|
|
|
when {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
status == null -> activity.showToast(true, result.error ?: "?")
|
|
|
|
|
replyId == null -> activity.showToast(
|
|
|
|
|
true,
|
2019-09-23 19:08:38 +02:00
|
|
|
|
"showReplyTootsearch: in_reply_to_id is null"
|
|
|
|
|
)
|
|
|
|
|
else -> conversationLocal(activity, pos, a, replyId)
|
2019-09-23 19:02:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
// step 1: choose account
|
|
|
|
|
|
|
|
|
|
val host = statusArg.account.apDomain
|
|
|
|
|
val local_account_list = ArrayList<SavedAccount>()
|
|
|
|
|
val other_account_list = ArrayList<SavedAccount>()
|
|
|
|
|
|
|
|
|
|
for (a in SavedAccount.loadAccountList(activity)) {
|
|
|
|
|
|
|
|
|
|
// 検索APIはログイン必須なので疑似アカウントは使えない
|
|
|
|
|
if (a.isPseudo) continue
|
|
|
|
|
|
|
|
|
|
if (a.matchHost(host)) {
|
|
|
|
|
local_account_list.add(a)
|
|
|
|
|
} else {
|
|
|
|
|
other_account_list.add(a)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val dialog = ActionsDialog()
|
|
|
|
|
|
|
|
|
|
SavedAccount.sort(local_account_list)
|
|
|
|
|
for (a in local_account_list) {
|
|
|
|
|
dialog.addAction(
|
2019-09-23 19:02:01 +02:00
|
|
|
|
AcctColor.getStringWithNickname(
|
|
|
|
|
activity,
|
|
|
|
|
R.string.open_in_account,
|
2020-02-02 15:19:57 +01:00
|
|
|
|
a.acct
|
2019-09-23 19:02:01 +02:00
|
|
|
|
)
|
|
|
|
|
) { step2(a) }
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SavedAccount.sort(other_account_list)
|
|
|
|
|
for (a in other_account_list) {
|
|
|
|
|
dialog.addAction(
|
2019-09-23 19:02:01 +02:00
|
|
|
|
AcctColor.getStringWithNickname(
|
|
|
|
|
activity,
|
|
|
|
|
R.string.open_in_account,
|
2020-02-02 15:19:57 +01:00
|
|
|
|
a.acct
|
2019-09-23 19:02:01 +02:00
|
|
|
|
)
|
|
|
|
|
) { step2(a) }
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialog.show(activity, activity.getString(R.string.open_status_from))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
// profile pin
|
|
|
|
|
|
|
|
|
|
fun pin(
|
|
|
|
|
activity: ActMain, access_info: SavedAccount, status: TootStatus, bSet: Boolean
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity)
|
|
|
|
|
.progressPrefix(activity.getString(R.string.profile_pin_progress))
|
|
|
|
|
|
|
|
|
|
.run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var new_status: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
2018-12-02 10:35:04 +01:00
|
|
|
|
val result = client.request(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
"/api/v1/statuses/${status.id}/${if (bSet) "pin" else "unpin"}",
|
2019-08-24 05:35:22 +02:00
|
|
|
|
"".toFormRequestBody().toPost()
|
2018-03-21 06:18:19 +01:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
new_status = TootParser(activity, access_info).status(result?.jsonObject)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return result
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
|
val new_status = this.new_status
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
when {
|
|
|
|
|
result == null -> {
|
|
|
|
|
// cancelled.
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-03-21 06:18:19 +01:00
|
|
|
|
new_status != null -> {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
for (column in activity.app_state.columnList) {
|
|
|
|
|
if (access_info == column.access_info) {
|
2018-03-21 06:18:19 +01:00
|
|
|
|
column.findStatus(
|
2020-09-07 14:20:11 +02:00
|
|
|
|
access_info.apDomain,
|
2018-03-21 06:18:19 +01:00
|
|
|
|
new_status.id
|
|
|
|
|
) { _, status ->
|
2018-01-20 17:59:38 +01:00
|
|
|
|
status.pinned = bSet
|
|
|
|
|
true
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-01-20 17:59:38 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2020-09-29 19:44:56 +02:00
|
|
|
|
else -> activity.showToast(true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// 結果に関わらず、更新中状態から復帰させる
|
|
|
|
|
activity.showColumnMatchAccount(access_info)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// reply
|
|
|
|
|
|
|
|
|
|
fun reply(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
status: TootStatus,
|
|
|
|
|
quote: Boolean = false
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
ActPost.open(
|
2018-08-31 12:29:34 +02:00
|
|
|
|
activity,
|
|
|
|
|
ActMain.REQUEST_CODE_POST,
|
|
|
|
|
access_info.db_id,
|
2018-11-27 17:53:27 +01:00
|
|
|
|
reply_status = status,
|
2020-02-23 14:48:32 +01:00
|
|
|
|
quote = quote
|
2018-08-31 12:29:34 +02:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun replyRemote(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
remote_status_url: String?,
|
|
|
|
|
quote: Boolean = false
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (remote_status_url == null || remote_status_url.isEmpty()) return
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity)
|
|
|
|
|
.progressPrefix(activity.getString(R.string.progress_synchronize_toot))
|
|
|
|
|
|
|
|
|
|
.run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var local_status: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
2019-06-26 08:47:47 +02:00
|
|
|
|
val (result, status) = client.syncStatus(access_info, remote_status_url)
|
2019-01-16 16:27:37 +01:00
|
|
|
|
local_status = status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return result
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
result ?: return // cancelled.
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val ls = local_status
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (ls != null) {
|
2020-02-23 14:48:32 +01:00
|
|
|
|
reply(activity, access_info, ls, quote = quote)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun replyFromAnotherAccount(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
timeline_account: SavedAccount,
|
|
|
|
|
status: TootStatus?,
|
|
|
|
|
quote: Boolean = false
|
2018-11-27 17:53:27 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
status ?: return
|
|
|
|
|
|
|
|
|
|
val accountCallback: SavedAccountCallback = { ai ->
|
|
|
|
|
if (ai.matchHost(status.readerApDomain)) {
|
|
|
|
|
// アクセス元ホストが同じならステータスIDを使って返信できる
|
|
|
|
|
reply(activity, ai, status, quote = quote)
|
|
|
|
|
} else {
|
|
|
|
|
// それ以外の場合、ステータスのURLを検索APIに投げることで返信できる
|
|
|
|
|
replyRemote(activity, ai, status.url, quote = quote)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (quote) {
|
|
|
|
|
AccountPicker.pick(
|
2018-11-27 17:53:27 +01:00
|
|
|
|
activity,
|
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAllowMisskey = true,
|
2020-02-23 14:48:32 +01:00
|
|
|
|
bAllowMastodon = true,
|
2018-11-27 17:53:27 +01:00
|
|
|
|
bAuto = true,
|
2020-02-23 14:48:32 +01:00
|
|
|
|
message = activity.getString(R.string.account_picker_quote_toot),
|
2018-11-27 17:53:27 +01:00
|
|
|
|
callback = accountCallback
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
} else {
|
|
|
|
|
AccountPicker.pick(
|
2018-11-27 17:53:27 +01:00
|
|
|
|
activity,
|
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAuto = false,
|
|
|
|
|
message = activity.getString(R.string.account_picker_reply),
|
2020-09-07 14:20:11 +02:00
|
|
|
|
accountListArg = makeAccountListNonPseudo(activity, timeline_account.apDomain),
|
2018-11-27 17:53:27 +01:00
|
|
|
|
callback = accountCallback
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 投稿画面を開く。初期テキストを指定する
|
|
|
|
|
fun redraft(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
accessInfo: SavedAccount,
|
|
|
|
|
status: TootStatus
|
2018-06-23 04:43:18 +02:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
activity.post_helper.closeAcctPopup()
|
|
|
|
|
|
|
|
|
|
if (accessInfo.isMisskey) {
|
|
|
|
|
ActPost.open(
|
2018-11-02 01:39:32 +01:00
|
|
|
|
activity,
|
|
|
|
|
ActMain.REQUEST_CODE_POST,
|
|
|
|
|
accessInfo.db_id,
|
|
|
|
|
redraft_status = status,
|
|
|
|
|
reply_status = status.reply
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (status.in_reply_to_id == null) {
|
|
|
|
|
ActPost.open(
|
2018-11-02 01:39:32 +01:00
|
|
|
|
activity,
|
|
|
|
|
ActMain.REQUEST_CODE_POST,
|
|
|
|
|
accessInfo.db_id,
|
|
|
|
|
redraft_status = status
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity).run(accessInfo, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var reply_status: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
2018-06-23 04:43:18 +02:00
|
|
|
|
val result = client.request("/api/v1/statuses/${status.in_reply_to_id}")
|
2018-08-20 19:37:42 +02:00
|
|
|
|
reply_status = TootParser(activity, accessInfo).status(result?.jsonObject)
|
2018-06-23 04:43:18 +02:00
|
|
|
|
return result
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
if (result == null) return // cancelled.
|
|
|
|
|
|
2018-06-23 04:43:18 +02:00
|
|
|
|
val reply_status = this.reply_status
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (reply_status != null) {
|
2018-08-31 12:29:34 +02:00
|
|
|
|
ActPost.open(
|
2018-08-20 19:37:42 +02:00
|
|
|
|
activity,
|
|
|
|
|
ActMain.REQUEST_CODE_POST,
|
|
|
|
|
accessInfo.db_id,
|
2018-08-31 12:29:34 +02:00
|
|
|
|
redraft_status = status,
|
|
|
|
|
reply_status = reply_status
|
2018-08-20 19:37:42 +02:00
|
|
|
|
)
|
2018-06-23 04:43:18 +02:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
val error = result.error ?: "(no information)"
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(true, activity.getString(R.string.cant_sync_toot) + " : $error")
|
2018-06-23 04:43:18 +02:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
fun muteConversation(
|
|
|
|
|
activity: ActMain, access_info: SavedAccount, status: TootStatus
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
// toggle change
|
|
|
|
|
val bMute = !status.muted
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity).run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var local_status: TootStatus? = null
|
|
|
|
|
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val result = client.request(
|
2021-01-03 06:11:04 +01:00
|
|
|
|
"/api/v1/statuses/${status.id}/${if (bMute) "mute" else "unmute"}",
|
2019-08-24 05:35:22 +02:00
|
|
|
|
"".toFormRequestBody().toPost()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
local_status = TootParser(activity, access_info).status(result?.jsonObject)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return result
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
result ?: return // cancelled.
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val ls = local_status
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (ls != null) {
|
|
|
|
|
for (column in activity.app_state.columnList) {
|
|
|
|
|
if (access_info == column.access_info) {
|
2020-09-07 14:20:11 +02:00
|
|
|
|
column.findStatus(access_info.apDomain, ls.id) { _, status ->
|
2018-01-20 17:59:38 +01:00
|
|
|
|
status.muted = bMute
|
|
|
|
|
true
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-01-20 17:59:38 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(
|
2018-03-21 06:18:19 +01:00
|
|
|
|
true,
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (bMute) R.string.mute_succeeded else R.string.unmute_succeeded
|
2018-03-21 06:18:19 +01:00
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun reaction(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
arg_status: TootStatus,
|
|
|
|
|
status_owner_acct: Acct,
|
|
|
|
|
nCrossAccountMode: Int,
|
|
|
|
|
callback: () -> Unit,
|
|
|
|
|
bSet: Boolean = true,
|
2021-01-03 12:49:21 +01:00
|
|
|
|
code: String? = null
|
2018-11-22 01:07:53 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (access_info.isPseudo || !access_info.isMisskey) return
|
|
|
|
|
|
|
|
|
|
// 自分の投稿にはリアクション出来ない
|
|
|
|
|
if (access_info.acct == status_owner_acct) {
|
|
|
|
|
activity.showToast(false, R.string.it_is_you)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-03 12:49:21 +01:00
|
|
|
|
if (code == null) {
|
|
|
|
|
if (!bSet) error("will not happen")
|
|
|
|
|
EmojiPicker(activity, access_info, closeOnSelected = true) { name, instance, _, _, _ ->
|
2021-02-20 12:22:22 +01:00
|
|
|
|
val item = EmojiMap.shortNameToEmojiInfo[name]
|
2021-01-03 12:49:21 +01:00
|
|
|
|
val newCode = if (item == null || instance != null) {
|
|
|
|
|
":$name:"
|
|
|
|
|
} else {
|
|
|
|
|
item.unified
|
|
|
|
|
}
|
|
|
|
|
reaction(
|
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
arg_status,
|
|
|
|
|
status_owner_acct,
|
|
|
|
|
nCrossAccountMode,
|
|
|
|
|
callback,
|
|
|
|
|
bSet,
|
|
|
|
|
newCode
|
|
|
|
|
)
|
|
|
|
|
}.show()
|
2021-01-03 06:11:04 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity, TootTaskRunner.PROGRESS_NONE).run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
|
|
|
|
val target_status = if (nCrossAccountMode == CROSS_ACCOUNT_REMOTE_INSTANCE) {
|
|
|
|
|
|
2019-06-26 08:47:47 +02:00
|
|
|
|
val (result, status) = client.syncStatus(access_info, arg_status)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-06-26 08:47:47 +02:00
|
|
|
|
status ?: return result
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
if (status.myReaction != null) {
|
2018-11-22 01:07:53 +01:00
|
|
|
|
return TootApiResult(activity.getString(R.string.already_reactioned))
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-16 16:27:37 +01:00
|
|
|
|
status
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-11-22 01:07:53 +01:00
|
|
|
|
} else {
|
|
|
|
|
// 既に自タンスのステータスがある
|
2019-01-16 16:27:37 +01:00
|
|
|
|
arg_status
|
2018-11-22 01:07:53 +01:00
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return if (!bSet) {
|
2018-11-22 01:07:53 +01:00
|
|
|
|
client.request(
|
|
|
|
|
"/api/notes/reactions/delete",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", target_status.id.toString())
|
|
|
|
|
}
|
2018-11-22 01:07:53 +01:00
|
|
|
|
.toPostRequestBuilder()
|
|
|
|
|
)
|
|
|
|
|
// 成功すると204 no content
|
|
|
|
|
} else {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-11-22 01:07:53 +01:00
|
|
|
|
client.request(
|
|
|
|
|
"/api/notes/reactions/create",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", target_status.id.toString())
|
|
|
|
|
put("reaction", code)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2020-01-07 09:03:32 +01:00
|
|
|
|
}
|
2018-11-22 01:07:53 +01:00
|
|
|
|
.toPostRequestBuilder()
|
|
|
|
|
)
|
|
|
|
|
// 成功すると204 no content
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
|
2018-11-22 01:07:53 +01:00
|
|
|
|
result ?: return
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2018-11-22 01:07:53 +01:00
|
|
|
|
val error = result.error
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (error != null) {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(false, error)
|
2018-11-22 01:07:53 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2020-09-29 19:44:56 +02:00
|
|
|
|
callback()
|
2018-11-22 01:07:53 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun reactionFromAnotherAccount(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
timeline_account: SavedAccount,
|
|
|
|
|
status: TootStatus?,
|
|
|
|
|
code: String? = null
|
2018-11-22 01:07:53 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
status ?: return
|
|
|
|
|
|
|
|
|
|
val status_owner = timeline_account.getFullAcct(status.account)
|
|
|
|
|
|
|
|
|
|
AccountPicker.pick(
|
2018-11-22 01:07:53 +01:00
|
|
|
|
activity,
|
|
|
|
|
bAllowPseudo = false,
|
|
|
|
|
bAllowMisskey = true,
|
|
|
|
|
bAllowMastodon = false,
|
|
|
|
|
bAuto = false,
|
|
|
|
|
message = activity.getString(R.string.account_picker_reaction)
|
|
|
|
|
) { action_account ->
|
2021-01-03 06:11:04 +01:00
|
|
|
|
reaction(
|
2018-11-22 01:07:53 +01:00
|
|
|
|
activity,
|
|
|
|
|
action_account,
|
|
|
|
|
status,
|
|
|
|
|
status_owner,
|
|
|
|
|
calcCrossAccountMode(timeline_account, action_account),
|
|
|
|
|
activity.reaction_complete_callback,
|
2021-01-03 12:49:21 +01:00
|
|
|
|
code = code
|
2018-11-22 01:07:53 +01:00
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun deleteScheduledPost(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
item: TootScheduled,
|
|
|
|
|
bConfirmed: Boolean = false,
|
|
|
|
|
callback: () -> Unit
|
2019-01-06 11:17:54 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (!bConfirmed) {
|
|
|
|
|
DlgConfirm.openSimple(
|
2019-01-06 15:55:25 +01:00
|
|
|
|
activity,
|
|
|
|
|
activity.getString(R.string.scheduled_status_delete_confirm)
|
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
deleteScheduledPost(
|
2019-01-06 15:55:25 +01:00
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
item,
|
|
|
|
|
bConfirmed = true,
|
|
|
|
|
callback = callback
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity).run(access_info, object : TootTask {
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
|
|
|
|
|
2019-01-06 11:17:54 +01:00
|
|
|
|
return client.request(
|
|
|
|
|
"/api/v1/scheduled_statuses/${item.id}",
|
|
|
|
|
Request.Builder().delete()
|
|
|
|
|
)
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
|
|
|
|
|
2019-01-06 11:17:54 +01:00
|
|
|
|
result ?: return
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-06 11:17:54 +01:00
|
|
|
|
val error = result.error
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (error != null) {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(false, error)
|
2019-01-06 11:17:54 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-06 11:17:54 +01:00
|
|
|
|
callback()
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun editScheduledPost(
|
|
|
|
|
activity: ActMain,
|
|
|
|
|
access_info: SavedAccount,
|
|
|
|
|
item: TootScheduled
|
2019-01-06 15:55:25 +01:00
|
|
|
|
) {
|
2021-01-03 06:11:04 +01:00
|
|
|
|
TootTaskRunner(activity).run(access_info, object : TootTask {
|
|
|
|
|
|
|
|
|
|
var reply_status: TootStatus? = null
|
|
|
|
|
override suspend fun background(client: TootApiClient): TootApiResult? {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
val reply_status_id = item.in_reply_to_id
|
|
|
|
|
?: return TootApiResult()
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-06 15:55:25 +01:00
|
|
|
|
return client.request("/api/v1/statuses/$reply_status_id")?.also { result ->
|
|
|
|
|
reply_status = TootParser(activity, access_info).status(result.jsonObject)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
|
|
|
|
override suspend fun handleResult(result: TootApiResult?) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
result ?: return
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-06 15:55:25 +01:00
|
|
|
|
val error = result.error
|
2021-01-03 06:11:04 +01:00
|
|
|
|
if (error != null) {
|
2020-09-29 19:44:56 +02:00
|
|
|
|
activity.showToast(false, error)
|
2019-01-06 15:55:25 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-06 15:55:25 +01:00
|
|
|
|
ActPost.open(
|
|
|
|
|
activity,
|
|
|
|
|
ActMain.REQUEST_CODE_POST,
|
|
|
|
|
access_info.db_id,
|
|
|
|
|
scheduledStatus = item,
|
|
|
|
|
reply_status = reply_status
|
|
|
|
|
)
|
2021-01-03 06:11:04 +01:00
|
|
|
|
|
2019-01-06 15:55:25 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-01-03 06:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|