Backport #1038 : Mastodon's API doesn't have `/api/direct_messages.json`
This commit is contained in:
parent
b52e511b9a
commit
d2e98524ac
|
@ -40,6 +40,9 @@ val AccountExtras.official: Boolean
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val AccountDetails.hasDm: Boolean
|
||||||
|
get() = type in arrayOf(AccountType.FANFOU, AccountType.TWITTER)
|
||||||
|
|
||||||
fun <T> AccountDetails.newMicroBlogInstance(context: Context, cls: Class<T>): T {
|
fun <T> AccountDetails.newMicroBlogInstance(context: Context, cls: Class<T>): T {
|
||||||
return credentials.newMicroBlogInstance(context, type, cls)
|
return credentials.newMicroBlogInstance(context, type, cls)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.mariotaku.sqliteqb.library.Expression
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_SHOW_NOTIFICATION
|
import org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_SHOW_NOTIFICATION
|
||||||
import org.mariotaku.twidere.annotation.AccountType
|
import org.mariotaku.twidere.annotation.AccountType
|
||||||
|
import org.mariotaku.twidere.exception.APINotSupportedException
|
||||||
import org.mariotaku.twidere.extension.findFieldByTypes
|
import org.mariotaku.twidere.extension.findFieldByTypes
|
||||||
import org.mariotaku.twidere.extension.model.*
|
import org.mariotaku.twidere.extension.model.*
|
||||||
import org.mariotaku.twidere.extension.model.api.target
|
import org.mariotaku.twidere.extension.model.api.target
|
||||||
|
@ -85,6 +86,7 @@ class GetMessagesTask(
|
||||||
}
|
}
|
||||||
val microBlog = details.newMicroBlogInstance(context, cls = MicroBlog::class.java)
|
val microBlog = details.newMicroBlogInstance(context, cls = MicroBlog::class.java)
|
||||||
val messages = try {
|
val messages = try {
|
||||||
|
if (!details.hasDm) throw APINotSupportedException(details.type)
|
||||||
getMessages(microBlog, details, param, i)
|
getMessages(microBlog, details, param, i)
|
||||||
} catch (e: MicroBlogException) {
|
} catch (e: MicroBlogException) {
|
||||||
return@forEachIndexed
|
return@forEachIndexed
|
||||||
|
|
Loading…
Reference in New Issue