fix forum topic slug creation
This commit is contained in:
parent
79c933b31e
commit
41813bb8a9
|
@ -38,6 +38,11 @@ case class Topic(
|
|||
|
||||
object Topic {
|
||||
|
||||
def nameToId(name: String) = (lila.common.String slugify name) |> { slug ⇒
|
||||
// if most chars are not latin, go for random slug
|
||||
(slug.size > (name.size / 2)).fold(slug, Random nextString 8)
|
||||
}
|
||||
|
||||
val idSize = 8
|
||||
|
||||
def make(
|
||||
|
|
|
@ -30,7 +30,7 @@ sealed abstract class TopicRepo(troll: Boolean) {
|
|||
$find.one(Json.obj("categId" -> categSlug, "slug" -> slug) ++ trollFilter)
|
||||
|
||||
def nextSlug(categ: Categ, name: String, it: Int = 1): Fu[String] = {
|
||||
val slug = lila.common.String.slugify(name) + ~(it == 1).option("-" + it)
|
||||
val slug = Topic.nameToId(name) + ~(it != 1).option("-" + it)
|
||||
// also take troll topic into accounts
|
||||
TopicRepoTroll.byTree(categ.slug, slug) flatMap {
|
||||
_.isDefined.fold(
|
||||
|
|
Loading…
Reference in a new issue