gosora/routes/moderate.go

31 lines
1.0 KiB
Go
Raw Normal View History

package routes
import (
2022-02-21 03:53:13 +00:00
"net/http"
2022-02-21 03:53:13 +00:00
c "git.tuxpa.in/a/gosora/common"
"git.tuxpa.in/a/gosora/common/phrases"
)
2020-06-08 07:04:47 +00:00
func IPSearch(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header) c.RouteError {
2022-02-21 03:32:53 +00:00
h.Title = phrases.GetTitlePhrase("ip_search")
// TODO: How should we handle the permissions if we extend this into an alt detector of sorts?
if !u.Perms.ViewIPs {
return c.NoPermissions(w, r, u)
}
2022-02-21 03:32:53 +00:00
// TODO: Reject IP Addresses with illegal characters
ip := c.SanitiseSingleLine(r.FormValue("ip"))
uids, err := c.IPSearch.Lookup(ip)
if err != nil {
return c.InternalError(err, w, r)
}
2022-02-21 03:32:53 +00:00
// TODO: What if a user is deleted via the Control Panel? We'll cross that bridge when we come to it, although we might lean towards blanking the account and removing the related data rather than purging it
userList, err := c.Users.BulkGetMap(uids)
if err != nil {
return c.InternalError(err, w, r)
}
return renderTemplate("ip_search", w, r, h, c.IPSearchPage{h, userList, ip})
}