2018-01-04 19:52:25 +01:00
|
|
|
package jp.juggler.subwaytooter.api.entity
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
import jp.juggler.subwaytooter.api.TootAccountMap
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.api.TootParser
|
2018-01-21 17:47:13 +01:00
|
|
|
import jp.juggler.subwaytooter.util.notEmptyOrThrow
|
2018-01-21 13:46:36 +01:00
|
|
|
import jp.juggler.subwaytooter.util.parseLong
|
|
|
|
import jp.juggler.subwaytooter.util.parseString
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 17:47:13 +01:00
|
|
|
import org.json.JSONObject
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
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
|
2018-05-08 10:25:02 +02:00
|
|
|
val accountRef : TootAccountRef?, // The Account sending the notification to the user
|
2018-01-10 16:47:35 +01:00
|
|
|
val status : TootStatus? // The Status associated with the notification, if applicable
|
2018-01-21 13:46:36 +01:00
|
|
|
) : TimelineItem() {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
val time_created_at : Long
|
2018-05-08 10:25:02 +02:00
|
|
|
|
|
|
|
val account : TootAccount?
|
|
|
|
get() = accountRef?.find()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
init {
|
2018-01-10 16:47:35 +01:00
|
|
|
time_created_at = TootStatus.parseTime(created_at)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
constructor(parser : TootParser, src : JSONObject) : this(
|
|
|
|
json = src,
|
2018-01-21 13:46:36 +01:00
|
|
|
id = src.parseLong("id") ?: - 1L,
|
2018-01-10 16:47:35 +01:00
|
|
|
type = src.notEmptyOrThrow("type"),
|
2018-01-21 13:46:36 +01:00
|
|
|
created_at = src.parseString("created_at"),
|
2018-05-08 10:25:02 +02:00
|
|
|
accountRef = TootAccountRef.mayNull( parser, parser.account(src.optJSONObject("account"))),
|
2018-01-21 17:47:13 +01:00
|
|
|
status = parser.status(src.optJSONObject("status"))
|
2018-01-10 16:47:35 +01:00
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
companion object {
|
|
|
|
const val TYPE_MENTION = "mention"
|
|
|
|
const val TYPE_REBLOG = "reblog"
|
|
|
|
const val TYPE_FAVOURITE = "favourite"
|
|
|
|
const val TYPE_FOLLOW = "follow"
|
|
|
|
}
|
|
|
|
}
|