Skip to content

Commit

Permalink
remove NetDomain("") after #16623
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 22, 2024
1 parent cd27d58 commit 403bb52
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/controllers/RelayRound.scala
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ final class RelayRound(
.find(userId)
.flatMapz(s => env.streamer.liveStreamApi.of(s).dmap(some))
.map:
_.flatMap(_.stream).map(_.urls(netDomain).toPair)
_.flatMap(_.stream).map(_.urls.toPair(netDomain))
case VideoEmbed.PinnedStream =>
fuccess:
rt.tour.pinnedStream
.ifFalse(rt.round.isFinished)
.flatMap(_.upstream)
.map(_.urls(netDomain).toPair)
.map(_.urls.toPair(netDomain))
case _ => fuccess(none)
crossSiteIsolation = videoUrls.isEmpty || (rt.tour.pinnedStream.isDefined && crossOriginPolicy
.supportsCredentiallessIFrames(ctx.req))
Expand Down
2 changes: 1 addition & 1 deletion modules/relay/src/main/JsonView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ final class JsonView(baseUrl: BaseUrl, markup: RelayMarkup, picfitUrl: PicfitUrl
.add("pinned" -> pinned.map: p =>
Json
.obj("name" -> p.name)
.add("redirect" -> p.upstream.map(_.urls(lila.core.config.NetDomain("")).redirect))
.add("redirect" -> p.upstream.map(_.urls.redirect))
.add("text" -> p.text)),
study = studyData.study,
analysis = studyData.analysis,
Expand Down
14 changes: 7 additions & 7 deletions modules/relay/src/main/RelayPinnedStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ case class RelayPinnedStream(name: String, url: URL, text: Option[String]):
case _ => none

object RelayPinnedStream:
case class Urls(embed: String, redirect: String):
def toPair = (embed, redirect)
case class Urls(embed: NetDomain => String, redirect: String):
def toPair(domain: NetDomain) = (embed(domain), redirect)
sealed trait Upstream:
def urls(parent: NetDomain): Urls
def urls: Urls
case class YouTube(id: String) extends Upstream:
def urls(parent: NetDomain) = Urls(
s"https://www.youtube.com/embed/${id}?disablekb=1&modestbranding=1&autoplay=1",
def urls = Urls(
_ => s"https://www.youtube.com/embed/${id}?disablekb=1&modestbranding=1&autoplay=1",
s"https://www.youtube.com/watch?v=${id}"
)
case class Twitch(id: String) extends Upstream:
def urls(parent: NetDomain) = Urls(
s"https://player.twitch.tv/?channel=${id}&parent=${parent}&autoplay=true",
def urls = Urls(
parent => s"https://player.twitch.tv/?channel=${id}&parent=${parent}&autoplay=true",
s"https://www.twitch.tv/${id}"
)
14 changes: 7 additions & 7 deletions modules/streamer/src/main/Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait Stream:
val status: Html
val streamer: Streamer
val lang: Lang
def urls(parent: NetDomain): Stream.Urls
def urls: Stream.Urls

def is[U: UserIdOf](u: U): Boolean = streamer.is(u)
def twitch = serviceName == "twitch"
Expand All @@ -28,8 +28,8 @@ object Stream:
case class Keyword(value: String) extends AnyRef with StringValue:
def toLowerCase = value.toLowerCase

case class Urls(embed: String, redirect: String):
def toPair = (embed, redirect)
case class Urls(embed: NetDomain => String, redirect: String):
def toPair(domain: NetDomain) = (embed(domain), redirect)

object Twitch:
case class TwitchStream(user_name: String, title: Html, `type`: String, language: String):
Expand All @@ -41,8 +41,8 @@ object Stream:
case class Stream(userId: String, status: Html, streamer: Streamer, lang: Lang)
extends lila.streamer.Stream:
def serviceName = "twitch"
def urls(parent: NetDomain) = Urls(
embed = s"https://player.twitch.tv/?channel=${userId}&parent=${parent}",
def urls = Urls(
embed = parent => s"https://player.twitch.tv/?channel=${userId}&parent=${parent}",
redirect = s"https://www.twitch.tv/${userId}"
)
private given Reads[TwitchStream] = Json.reads
Expand Down Expand Up @@ -83,8 +83,8 @@ object Stream:
lang: Lang
) extends lila.streamer.Stream:
def serviceName = "youTube"
def urls(parent: NetDomain) = Urls(
embed = s"https://www.youtube.com/embed/${videoId}?autoplay=1&disablekb=1&color=white",
def urls = Urls(
embed = _ => s"https://www.youtube.com/embed/${videoId}?autoplay=1&disablekb=1&color=white",
redirect = s"https://www.youtube.com/watch?v=${videoId}"
)

Expand Down

0 comments on commit 403bb52

Please sign in to comment.