This commit is contained in:
tateisu 2020-02-11 09:35:44 +09:00
parent 2c16da21e0
commit 28ba7ead09
2 changed files with 12 additions and 12 deletions

View File

@ -20,7 +20,6 @@ import java.io.FileOutputStream
import java.io.IOException
import java.io.InputStream
import java.util.*
import java.util.regex.Pattern
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream

View File

@ -130,12 +130,20 @@ open class TootAccount(parser : TootParser, src : JsonObject) {
parseMapOrNull(CustomEmoji.decodeMisskey, src.jsonArray("emojis"))
this.profile_emojis = null
this.host = src.string("host")?.let { Host.parse(it) } ?: parser.accessHost
?: error("missing host")
this.username = src.notEmptyOrThrow("username")
this.host = src.string("host")?.let { Host.parse(it) }
?: parser.accessHost
?: error("missing host")
this.url = "https://${host.ascii}/@$username"
this.acct = when(host) {
// アクセス元から見て内部ユーザなら short acct
parser.accessHost -> Acct.parse(username)
// アクセス元から見て外部ユーザならfull acct
else -> Acct.parse(username, host)
}
//
val sv = src.string("name")
this.display_name = if(sv?.isNotEmpty() == true) sv.sanitizeBDI() else username
@ -158,14 +166,7 @@ open class TootAccount(parser : TootParser, src : JsonObject) {
this.id = EntityId.mayDefault(src.string("id"))
this.acct = when(host) {
// アクセス元から見て内部ユーザなら short acct
parser.accessHost -> Acct.parse(username)
// アクセス元から見て外部ユーザならfull acct
else -> Acct.parse(username, host)
}
this.followers_count = src.long("followersCount") ?: - 1L
this.following_count = src.long("followingCount") ?: - 1L
this.statuses_count = src.long("notesCount") ?: - 1L