filter profile info for mobile app
parent
6fc82e775a
commit
8793e9077d
|
@ -23,7 +23,7 @@ final class JsonView(isOnline: lila.socket.IsOnline) {
|
|||
)
|
||||
.add("disabled" -> u.disabled)
|
||||
.add("tosViolation" -> u.lame)
|
||||
.add("profile" -> u.profile.map(p => profileWrites.writes(p).noNull))
|
||||
.add("profile" -> u.profile.map(p => profileWrites.writes(p.filterTroll(u.marks.troll)).noNull))
|
||||
.add("seenAt" -> u.seenAt)
|
||||
.add("patron" -> u.isPatron)
|
||||
.add("playTime" -> u.playTime)
|
||||
|
|
|
@ -45,6 +45,14 @@ case class Profile(
|
|||
cfcRating.map { OfficialRating("cfc", _) } orElse
|
||||
dsbRating.map { OfficialRating("dsb", _) }
|
||||
|
||||
def filterTroll(troll: Boolean) = copy(
|
||||
bio = bio ifFalse troll,
|
||||
firstName = firstName ifFalse troll,
|
||||
lastName = lastName ifFalse troll,
|
||||
location = location ifFalse troll,
|
||||
links = links ifFalse troll
|
||||
)
|
||||
|
||||
private def ne(str: Option[String]) = str.filter(_.nonEmpty)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue