Introduced length limits
This commit is contained in:
arn
mixins
pages
animelistitem
newthread
search
settings
welcome
scripts/Actions
utils/editform
@ -1,16 +1,24 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aerogo/flow"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// MinimumStringSimilarity is the minimum JaroWinkler distance we accept for search results.
|
||||
const MinimumStringSimilarity = 0.89
|
||||
// MinStringSimilarity is the minimum JaroWinkler distance we accept for search results.
|
||||
const MinStringSimilarity = 0.89
|
||||
|
||||
// MaxSearchTermLength defines how long the search term can be.
|
||||
const MaxSearchTermLength = 100
|
||||
|
||||
// popularityDamping reduces the factor of popularity in search results.
|
||||
const popularityDamping = 0.0009
|
||||
|
||||
// ErrTermTooLong is used when the search term is too long
|
||||
var ErrTermTooLong = fmt.Errorf("Search term is too long (maximum %d characters)", MaxSearchTermLength)
|
||||
|
||||
// Result ...
|
||||
type Result struct {
|
||||
obj interface{}
|
||||
@ -23,6 +31,10 @@ func All(term string, maxUsers, maxAnime, maxPosts, maxThreads, maxTracks, maxCh
|
||||
return nil, nil, nil, nil, nil, nil, nil, nil
|
||||
}
|
||||
|
||||
if len(term) > MaxSearchTermLength {
|
||||
return nil, nil, nil, nil, nil, nil, nil, nil
|
||||
}
|
||||
|
||||
var (
|
||||
userResults []*arn.User
|
||||
animeResults []*arn.Anime
|
||||
|
Reference in New Issue
Block a user