fix forum topic slug creation

This commit is contained in:
Thibault Duplessis 2013-06-03 14:15:37 +02:00
parent 79c933b31e
commit 41813bb8a9
2 changed files with 6 additions and 1 deletions

View file

@ -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(

View file

@ -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(