SubwayTooter-Android-App/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootNotification.kt

45 lines
1.3 KiB
Kotlin
Raw Normal View History

package jp.juggler.subwaytooter.api.entity
import org.json.JSONObject
import jp.juggler.subwaytooter.api.TootParser
import jp.juggler.subwaytooter.util.parseLong
import jp.juggler.subwaytooter.util.parseString
class TootNotification(
val json : JSONObject,
val id : Long,
val type : String, // One of: "mention", "reblog", "favourite", "follow"
2018-01-12 10:01:25 +01:00
private val created_at : String?, // The time the notification was created
val account : TootAccount?, // The Account sending the notification to the user
val status : TootStatus? // The Status associated with the notification, if applicable
) : TimelineItem() {
val time_created_at : Long
init {
time_created_at = TootStatus.parseTime(created_at)
}
constructor(parser : TootParser, src : JSONObject) : this(
json = src,
id = src.parseLong("id") ?: - 1L,
type = src.notEmptyOrThrow("type"),
created_at = src.parseString("created_at"),
account = TootAccount.parse(
parser.context,
parser.accessInfo,
src.optJSONObject("account"),
ServiceType.MASTODON
),
status = TootStatus.parse(parser, src.optJSONObject("status"), ServiceType.MASTODON)
)
companion object {
const val TYPE_MENTION = "mention"
const val TYPE_REBLOG = "reblog"
const val TYPE_FAVOURITE = "favourite"
const val TYPE_FOLLOW = "follow"
}
}