mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-04 20:16:24 -07:00
Fix recent post checking
This commit is contained in:
parent
30b5a84aab
commit
fd6ca5d38c
3 changed files with 112 additions and 75 deletions
|
@ -171,21 +171,38 @@ var actions = []Action{
|
|||
Permissions: JanitorPerms,
|
||||
JSONoutput: OptionalJSON,
|
||||
Callback: func(writer http.ResponseWriter, request *http.Request, staff *gcsql.Staff, wantsJSON bool, infoEv, errEv *zerolog.Event) (output interface{}, err error) {
|
||||
limit, err := getIntField("limit", staff.Username, request, 0)
|
||||
limit := 20
|
||||
limitStr := request.FormValue("limit")
|
||||
if limitStr != "" {
|
||||
limit, err = strconv.Atoi(limitStr)
|
||||
if err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
boardidStr := request.FormValue("boardid")
|
||||
var recentposts []building.PostJSON
|
||||
var boardid int
|
||||
if boardidStr != "" {
|
||||
if boardid, err = strconv.Atoi(boardidStr); err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
recentposts, err = building.GetRecentPosts(boardid, limit)
|
||||
if err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return "", err
|
||||
}
|
||||
boardid, err := getIntField("boardid", staff.Username, request, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
recentposts, err := building.GetRecentPosts(boardid, limit)
|
||||
if err != nil {
|
||||
return "", err
|
||||
if wantsJSON {
|
||||
return recentposts, nil
|
||||
}
|
||||
manageRecentsBuffer := bytes.NewBufferString("")
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ManageRecentPosts, map[string]interface{}{
|
||||
"recentposts": recentposts,
|
||||
"allBoards": gcsql.AllBoards,
|
||||
"boardid": boardid,
|
||||
"limit": limit,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
}, manageRecentsBuffer, "text/html"); err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
|
@ -194,30 +211,6 @@ var actions = []Action{
|
|||
return manageRecentsBuffer.String(), nil
|
||||
},
|
||||
},
|
||||
// {
|
||||
// ID: "recentposts",
|
||||
// Title: "Recent posts",
|
||||
// Permissions: JanitorPerms,
|
||||
// JSONoutput: OptionalJSON,
|
||||
// Callback: func(writer http.ResponseWriter, request *http.Request, staff *gcsql.Staff, wantsJSON bool) (output interface{}, err error) {
|
||||
// limit := gcutil.HackyStringToInt(request.FormValue("limit"))
|
||||
// if limit == 0 {
|
||||
// limit = 50
|
||||
// }
|
||||
// recentposts, err := gcsql.GetRecentPostsGlobal(limit, false) //only uses boardname, boardid, postid, parentid, message, ip and timestamp
|
||||
// if wantsJSON || err != nil {
|
||||
// return recentposts, err
|
||||
// }
|
||||
// manageRecentsBuffer := bytes.NewBufferString("")
|
||||
// if err = serverutil.MinifyTemplate(gctemplates.ManageRecentPosts, map[string]interface{}{
|
||||
// "recentposts": recentposts,
|
||||
// "webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
// }, manageRecentsBuffer, "text/html"); err != nil {
|
||||
// errEv.Err(err).Caller().Send()
|
||||
// return "", errors.New("Error executing ban management page template: " + err.Error())
|
||||
// }
|
||||
// return manageRecentsBuffer.String(), nil
|
||||
// }},
|
||||
/* {
|
||||
ID: "filebans",
|
||||
Title: "File bans",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue