Improved stability, improved spam algorithm, fixed some bugs

This commit is contained in:
Tim Schuster committed 2017-03-15 09:13:15 +01:00
1 parent afd9ae71cf
commit 19d0e9282d
37 files changed
+2099 -255

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
package middle
import (
"go.rls.moe/nyx/config"
"net/http"
)
func LimitSize(c *config.Config) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)
next.ServeHTTP(w, r)
})
}
}
+23
View File
@@ -13,3 +13,26 @@ func init() {
func GetSession(r *http.Request) session.Session {
return session.Get(r)
}
func IsAdminSession(sess session.Session) bool {
if sess == nil {
return false
}
if sess.CAttr("mode") == "admin" {
return true
}
return false
}
func IsModSession(sess session.Session) bool {
if sess == nil {
return false
}
if IsAdminSession(sess) {
return true
}
if sess.CAttr("mode") == "mod" {
return true
}
return false
}