diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt index 4007130fb..073998137 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt @@ -40,6 +40,9 @@ val AccountExtras.official: Boolean return false } +val AccountDetails.hasDm: Boolean + get() = type in arrayOf(AccountType.FANFOU, AccountType.TWITTER) + fun AccountDetails.newMicroBlogInstance(context: Context, cls: Class): T { return credentials.newMicroBlogInstance(context, type, cls) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt index b294b2b42..4765f3e36 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt @@ -37,6 +37,7 @@ import org.mariotaku.sqliteqb.library.Expression import org.mariotaku.twidere.R import org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_SHOW_NOTIFICATION import org.mariotaku.twidere.annotation.AccountType +import org.mariotaku.twidere.exception.APINotSupportedException import org.mariotaku.twidere.extension.findFieldByTypes import org.mariotaku.twidere.extension.model.* import org.mariotaku.twidere.extension.model.api.target @@ -85,6 +86,7 @@ class GetMessagesTask( } val microBlog = details.newMicroBlogInstance(context, cls = MicroBlog::class.java) val messages = try { + if (!details.hasDm) throw APINotSupportedException(details.type) getMessages(microBlog, details, param, i) } catch (e: MicroBlogException) { return@forEachIndexed