Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Make commentlength and descriptionlength configurable

Cette révision appartient à :
PantsuDev 2017-06-22 10:21:51 +10:00
Parent 424a62549c
révision 1936c74085
4 fichiers modifiés avec 6 ajouts et 2 suppressions

Voir le fichier

@ -19,6 +19,8 @@ environment: DEVELOPMENT
auth_token_expiration: 1000
# EnableSecureCSRF : Enable CSRF https mode : True if website support https, false otherwise (eg. testing locally: false)
enable_secure_csrf: true
description_length: 10000
comment_length: 2000
# the default config for web addresses
web_address:
# Nyaa : Origin of the website

Voir le fichier

@ -8,6 +8,8 @@ type Config struct {
Environment string `json:"environment" yaml:"environment,omitempty"`
AuthTokenExpirationDay int `json:"auth_token_expiration" yaml:"auth_token_expiration,omitempty"`
EnableSecureCSRF bool `json:"enable_secure_csrf" yaml:"enable_secure_csrf,omitempty"`
DescriptionLength int `json:"description_length" yaml:"description_length,omitempty"`
CommentLength int `json:"comment_length" yaml:"comment_length,omitempty"`
// DBParams will be directly passed to Gorm, and its internal
// structure depends on the dialect for each db type
DBParams string `json:"db_params" yaml:"db_params,omitempty"`

Voir le fichier

@ -110,7 +110,7 @@ func PostCommentHandler(w http.ResponseWriter, r *http.Request) {
if strings.TrimSpace(content) == "" {
messages.AddErrorT("errors", "comment_empty")
}
if len(content) > 500 {
if len(content) > config.Conf.CommentLength {
messages.AddErrorT("errors", "comment_toolong")
}
if !messages.HasErrors() {

Voir le fichier

@ -152,7 +152,7 @@ func (r *TorrentRequest) validateName() error {
}
func (r *TorrentRequest) validateDescription() error {
if len(r.Description) > 500 {
if len(r.Description) > config.Conf.DescriptionLength {
return errInvalidTorrentDescription
}
return nil