-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathblacklist.go
40 lines (35 loc) · 944 Bytes
/
blacklist.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package ui
import (
"dhtc/db"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"net/http"
)
func (c *Controller) BlacklistGet(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "blacklist", gin.H{
"path": ctx.FullPath(),
"results": db.GetBlacklistEntries(c.Database),
})
}
func (c *Controller) BlacklistPost(ctx *gin.Context) {
opOk := false
op := ctx.PostForm("op")
if op == "add" {
opOk = db.AddToBlacklist(c.Database, []string{ctx.PostForm("Filter")}, ctx.PostForm("Type"))
} else if op == "delete" {
opOk = db.DeleteBlacklistItem(c.Database, ctx.PostForm("Id"))
} else if op == "enable" {
c.Configuration.EnableBlacklist = true
opOk = true
} else if op == "disable" {
c.Configuration.EnableBlacklist = false
opOk = true
}
log.Print(opOk)
ctx.HTML(http.StatusOK, "blacklist", gin.H{
"path": ctx.FullPath(),
"op": op,
"opOk": opOk,
"results": db.GetBlacklistEntries(c.Database),
})
}