gosora/routes/moderate.go
Azareal bf851bd9fc We now use Go 1.11 modules. This should help with build times, deployment and development, although it does mean that the minimum requirement for Gosora has been bumped up from Go 1.10 to Go 1.11
Added support for dyntmpl to the template system.
The Account Dashboard now sort of uses dyntmpl, more work needed here.
Renamed the pre_render_view_topic hook to pre_render_topic.
Added the GetCurrentLangPack() function.
Added the alerts_no_new_alerts phrase.
Added the account_level_list phrase.

Refactored the route rename logic in the patcher to cut down on the amount of boilerplate.
Added more route renames to the patcher. You will need to run the patcher / updater in this commit.
2018-10-27 13:40:36 +10:00

44 lines
1.3 KiB
Go

package routes
import (
"net/http"
"github.com/Azareal/Gosora/common"
)
func IPSearch(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
header, ferr := common.UserCheck(w, r, &user)
if ferr != nil {
return ferr
}
header.Title = common.GetTitlePhrase("ip_search")
// TODO: How should we handle the permissions if we extend this into an alt detector of sorts?
if !user.Perms.ViewIPs {
return common.NoPermissions(w, r, user)
}
// TODO: Reject IP Addresses with illegal characters
var ip = common.SanitiseSingleLine(r.FormValue("ip"))
uids, err := common.IPSearch.Lookup(ip)
if err != nil {
return common.InternalError(err, w, r)
}
// 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 := common.Users.BulkGetMap(uids)
if err != nil {
return common.InternalError(err, w, r)
}
pi := common.IPSearchPage{header, userList, ip}
if common.RunPreRenderHook("pre_render_ip_search", w, r, &user, &pi) {
return nil
}
err = common.RunThemeTemplate(header.Theme.Name, "ip_search", pi, w)
if err != nil {
return common.InternalError(err, w, r)
}
return nil
}