1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-02 09:46:51 +01:00

throw exception for malformed status object

This commit is contained in:
Mariotaku Lee 2017-05-15 10:04:31 +08:00
parent 2f0c2c87b1
commit 3091b5901b
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,24 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.exception
import org.mariotaku.microblog.library.MicroBlogException
class MalformedResponseException : MicroBlogException("Malformed response object")

View File

@ -30,6 +30,7 @@ import org.mariotaku.microblog.library.twitter.model.EntitySupport
import org.mariotaku.microblog.library.twitter.model.ExtendedEntitySupport
import org.mariotaku.microblog.library.twitter.model.MediaEntity
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.exception.MalformedResponseException
import org.mariotaku.twidere.extension.model.toParcelable
import org.mariotaku.twidere.extension.toSpanItem
import org.mariotaku.twidere.model.*
@ -103,7 +104,7 @@ fun Status.applyTo(accountKey: UserKey, accountType: String, profileImageSize: S
result.is_quote = status.isQuoteStatus
result.quoted_id = status.quotedStatusId
if (quoted != null) {
val quotedUser = quoted.user
val quotedUser = quoted.user ?: throw MalformedResponseException()
result.quoted_id = quoted.id
extras.quoted_external_url = quoted.inferredExternalUrl
@ -150,7 +151,7 @@ fun Status.applyTo(accountKey: UserKey, accountType: String, profileImageSize: S
result.in_reply_to_status_id = status.inReplyToStatusId
result.in_reply_to_user_key = status.getInReplyToUserKey(accountKey)
val user = status.user
val user = status.user ?: throw MalformedResponseException()
result.user_key = user.key
result.user_name = user.name
result.user_screen_name = user.screenName