0
0
mirror of https://github.com/rls-moe/nyx synced 2025-08-19 06:18:38 +00:00

Improved stability, improved spam algorithm, fixed some bugs

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

15
http/middle/limitsize.go Normal file
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)
})
}
}

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
}