mirror of
https://github.com/lichess-org/lila.git
synced 2026-05-26 13:51:00 +00:00
26 lines
741 B
Scala
26 lines
741 B
Scala
package lila.push
|
|
|
|
import scala.math.Ordered.orderingToOrdered
|
|
import scalalib.net.UserAgent
|
|
|
|
import lila.core.net.LichessMobileVersion
|
|
import lila.common.HTTPRequest
|
|
import LichessMobileVersion.given
|
|
|
|
final private case class Device(
|
|
_id: String, // Firebase token
|
|
platform: String, // cordova platform (android, ios, firebase)
|
|
userId: UserId,
|
|
seenAt: Instant,
|
|
ua: UserAgent
|
|
):
|
|
def isMobile = HTTPRequest.isLichessMobile(ua)
|
|
def isLichobile = HTTPRequest.isLichobile(ua)
|
|
|
|
def isMobileVersionCompatible(version: LichessMobileVersion): Boolean =
|
|
HTTPRequest.lichessMobileVersion(ua).exists(_ >= version)
|
|
|
|
def deviceId = platform match
|
|
case "ios" => _id.grouped(8).mkString("<", " ", ">")
|
|
case _ => _id
|