Merge pull request #8048 from kraktus/pub-chat

Do not expand images for mods
pull/8052/head
Thibault Duplessis 2021-01-30 18:26:04 +01:00 committed by GitHub
commit 847f571fb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 8 deletions

View File

@ -53,7 +53,7 @@ object inquiry {
def renderNote(r: lila.user.Note)(implicit ctx: Context) =
(!r.dox || isGranted(_.Doxing)) option div(cls := "doc note")(
h3("by ", userIdLink(r.from.some, withOnline = false), ", ", momentFromNow(r.date)),
p(richText(r.text))
p(richText(r.text, expandImg = false))
)
def autoNextInput = input(cls := "auto-next", tpe := "hidden", name := "next", value := "1")

View File

@ -32,7 +32,7 @@ object publicChat {
div(cls := "line")(
userIdLink(line.author.toLowerCase.some, withOnline = false, withTitle = false),
" ",
richText(line.text)
richText(line.text, expandImg = false)
)
}
)
@ -50,7 +50,7 @@ object publicChat {
div(cls := "line")(
userIdLink(line.author.toLowerCase.some, withOnline = false, withTitle = false),
" ",
richText(line.text)
richText(line.text, expandImg = false)
)
}
)

View File

@ -158,7 +158,7 @@ object header {
}
.map { note =>
div(cls := "note")(
p(cls := "note__text")(richText(note.text)),
p(cls := "note__text")(richText(note.text, expandImg = false)),
p(cls := "note__meta")(
userIdLink(note.from.some),
br,

View File

@ -69,9 +69,9 @@ object String {
object html {
def richText(rawText: String, nl2br: Boolean = true): Frag =
def richText(rawText: String, nl2br: Boolean = true, expandImg: Boolean = true): Frag =
raw {
val withLinks = RawHtml.addLinks(rawText)
val withLinks = RawHtml.addLinks(rawText, expandImg)
if (nl2br) RawHtml.nl2br(withLinks) else withLinks
}

View File

@ -64,7 +64,7 @@ final object RawHtml {
def hasLinks(text: String) = urlPattern.matcher(text).find
def addLinks(text: String): String =
def addLinks(text: String, expandImg: Boolean = true): String =
expandAtUser(text).map { expanded =>
val m = urlPattern.matcher(expanded)
@ -117,7 +117,7 @@ final object RawHtml {
val url = (if (isHttp) "http://" else "https://") + allButScheme
val text = if (isHttp) url else allButScheme
val imgHtml = {
if (end < sArr.length && sArr(end) == '"') None
if ((end < sArr.length && sArr(end) == '"') || !expandImg) None
else imgUrl(url)
}
sb.append(