2018-01-04 19:52:25 +01:00
|
|
|
package jp.juggler.subwaytooter.api.entity
|
|
|
|
|
2018-11-01 13:48:54 +01:00
|
|
|
import jp.juggler.subwaytooter.api.TootParser
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.table.UserRelation
|
2020-01-07 09:03:32 +01:00
|
|
|
import jp.juggler.util.JsonObject
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2020-01-07 09:03:32 +01:00
|
|
|
class TootRelationShip(parser:TootParser,src : JsonObject) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// Target account id
|
2018-11-01 13:48:54 +01:00
|
|
|
// MisskeyのユーザリレーションはuserIdを含まないので後から何か設定する必要がある
|
|
|
|
var id : EntityId
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// Whether the authorized user is currently following the target account.
|
|
|
|
// maybe faked in response of follow-request.
|
2018-01-10 16:47:35 +01:00
|
|
|
val following : Boolean
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// Whether the authorized user is currently being followed by the target account.
|
2018-01-10 16:47:35 +01:00
|
|
|
val followed_by : Boolean
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// Whether the authorized user is currently blocking the target account.
|
2018-01-10 16:47:35 +01:00
|
|
|
val blocking : Boolean
|
2018-11-01 13:48:54 +01:00
|
|
|
|
2019-03-26 02:50:37 +01:00
|
|
|
// misskeyとMastodon 2.8.0以降
|
2018-11-01 13:48:54 +01:00
|
|
|
val blocked_by : Boolean
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// Whether the authorized user is currently muting the target account.
|
2018-01-10 16:47:35 +01:00
|
|
|
val muting : Boolean
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// Whether the authorized user has requested to follow the target account.
|
|
|
|
// maybe true while follow-request is progress on server, even if the user is not locked.
|
2018-01-10 16:47:35 +01:00
|
|
|
val requested : Boolean
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// (mastodon 2.1 or later) per-following-user setting.
|
|
|
|
// Whether the boosts from target account will be shown on authorized user's home TL.
|
2018-01-10 16:47:35 +01:00
|
|
|
val showing_reblogs : Int
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-08-28 14:25:45 +02:00
|
|
|
// 「プロフィールで紹介する」「プロフィールから外す」
|
|
|
|
val endorsed : Boolean
|
|
|
|
|
2018-11-01 13:48:54 +01:00
|
|
|
// misskey用
|
|
|
|
val requested_by : Boolean
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
init {
|
2018-10-30 20:29:00 +01:00
|
|
|
|
2018-11-01 13:48:54 +01:00
|
|
|
if( parser.serviceType == ServiceType.MISSKEY){
|
2019-01-29 02:56:24 +01:00
|
|
|
this.id = EntityId.DEFAULT
|
2018-01-10 16:47:35 +01:00
|
|
|
|
2018-11-01 13:48:54 +01:00
|
|
|
following = src.optBoolean("isFollowing")
|
|
|
|
followed_by = src.optBoolean("isFollowed")
|
|
|
|
muting = src.optBoolean("isMuted")
|
|
|
|
blocking = src.optBoolean("isBlocking")
|
|
|
|
blocked_by = src.optBoolean("isBlocked")
|
|
|
|
requested = src.optBoolean("hasPendingFollowRequestFromYou")
|
|
|
|
requested_by = src.optBoolean("hasPendingFollowRequestToYou")
|
2018-01-10 16:47:35 +01:00
|
|
|
|
2018-11-01 13:48:54 +01:00
|
|
|
endorsed = false
|
|
|
|
showing_reblogs = UserRelation.REBLOG_UNKNOWN
|
|
|
|
|
|
|
|
}else{
|
2019-01-28 19:02:09 +01:00
|
|
|
this.id = EntityId.mayDefault( src.parseString("id") )
|
2018-01-10 16:47:35 +01:00
|
|
|
|
2020-01-07 09:03:32 +01:00
|
|
|
var ov = src["following"]
|
|
|
|
if(ov is JsonObject) {
|
2018-11-01 13:48:54 +01:00
|
|
|
// https://github.com/tootsuite/mastodon/issues/5856
|
|
|
|
// 一部の開発版ではこうなっていた
|
|
|
|
|
|
|
|
this.following = true
|
|
|
|
|
2020-01-07 09:03:32 +01:00
|
|
|
ov = ov["reblogs"]
|
2018-11-01 13:48:54 +01:00
|
|
|
if(ov is Boolean) {
|
|
|
|
this.showing_reblogs = if(ov) UserRelation.REBLOG_SHOW else UserRelation.REBLOG_HIDE
|
|
|
|
} else {
|
|
|
|
this.showing_reblogs = UserRelation.REBLOG_UNKNOWN
|
|
|
|
}
|
2018-01-10 16:47:35 +01:00
|
|
|
} else {
|
2018-11-01 13:48:54 +01:00
|
|
|
// 2.0 までの挙動
|
|
|
|
this.following = if(ov is Boolean) ov else false
|
|
|
|
|
|
|
|
// 2.1 の挙動
|
2020-01-07 09:03:32 +01:00
|
|
|
ov = src["showing_reblogs"]
|
2018-11-01 13:48:54 +01:00
|
|
|
if(this.following && ov is Boolean) {
|
|
|
|
this.showing_reblogs = if(ov) UserRelation.REBLOG_SHOW else UserRelation.REBLOG_HIDE
|
|
|
|
} else {
|
|
|
|
this.showing_reblogs = UserRelation.REBLOG_UNKNOWN
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
2018-11-01 13:48:54 +01:00
|
|
|
|
|
|
|
this.followed_by = src.optBoolean("followed_by")
|
|
|
|
this.blocking = src.optBoolean("blocking")
|
|
|
|
this.muting = src.optBoolean("muting")
|
|
|
|
this.requested = src.optBoolean("requested")
|
|
|
|
this.endorsed = src.optBoolean("endorsed")
|
|
|
|
|
2019-03-26 02:50:37 +01:00
|
|
|
// https://github.com/tootsuite/mastodon/commit/9745de883b198375ba23f7fde879f6d75ce2df0f
|
|
|
|
// Mastodon 2.8.0から
|
|
|
|
this.blocked_by = src.optBoolean("blocked_by")
|
|
|
|
|
2018-11-01 13:48:54 +01:00
|
|
|
requested_by = false
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
2018-01-10 16:47:35 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|