Add DisablePollIP configuration setting.

This commit is contained in:
Azareal 2020-01-02 19:49:34 +10:00
parent 0d81557009
commit aed409ae9e
4 changed files with 15 additions and 4 deletions

View File

@ -234,8 +234,11 @@ func (s *DefaultPollStore) unpackOptionsMap(rawOptions map[int]string) []PollOpt
} }
// TODO: Use a transaction for this? // TODO: Use a transaction for this?
func (s *DefaultPollStore) CastVote(optionIndex int, pollID int, uid int, ipaddress string) error { func (s *DefaultPollStore) CastVote(optionIndex int, pollID int, uid int, ip string) error {
_, err := s.addVote.Exec(pollID, uid, optionIndex, ipaddress) if Config.DisablePollIP {
ip = "0"
}
_, err := s.addVote.Exec(pollID, uid, optionIndex, ip)
if err != nil { if err != nil {
return err return err
} }

View File

@ -97,6 +97,7 @@ type config struct {
LogPruneCutoff int LogPruneCutoff int
DisableLastIP bool DisableLastIP bool
DisablePollIP bool
DisableLiveTopicList bool DisableLiveTopicList bool
DisableJSAntispam bool DisableJSAntispam bool

View File

@ -88,10 +88,12 @@ LastIPCutoff - The number of months which need to pass before the last IP stored
PostIPCutoff - The number of days which need to pass before the IP data for a post is automatically deleted. 0 defaults to whatever the current default is, currently 120 and -1 disables this feature. PostIPCutoff - The number of days which need to pass before the IP data for a post is automatically deleted. 0 defaults to whatever the current default is, currently 120 and -1 disables this feature.
PollIPCutoff - The number of days which need to pass before the IP data for a poll is automatically deleted. 0 defaults to whatever the current default is, currently -1 and -1 disables this feature. PollIPCutoff - The number of days which need to pass before the IP data for a poll is automatically deleted. 0 defaults to whatever the current default is, currently 365 and -1 disables this feature.
DisableLastIP - Disable storing last IPs for users and purge any existing user last IP data. Default: false DisableLastIP - Disable storing last IPs for users and purge any existing user last IP data. Default: false
DisablePollIP - Disable storing poll vote IPs and purge any existing poll vote IP data. Default: false
LogPruneCutoff - The number of days which need to pass before the login and registration logs are pruned. 0 defaults to whatever the current default is, currently 180 and -1 disables this feature. LogPruneCutoff - The number of days which need to pass before the login and registration logs are pruned. 0 defaults to whatever the current default is, currently 180 and -1 disables this feature.
DisableLiveTopicList - This switch allows you to disable the live topic list. Default: false DisableLiveTopicList - This switch allows you to disable the live topic list. Default: false

View File

@ -194,7 +194,12 @@ func dailies() {
f("users_replies") f("users_replies")
} }
if c.Config.PollIPCutoff > -1 { if c.Config.DisablePollIP {
_, err := qgen.NewAcc().Update("polls_votes").Set("ipaddress='0'").Where("ipaddress!='0'").Exec()
if err != nil {
c.LogError(err)
}
} else if c.Config.PollIPCutoff > -1 {
// TODO: Use unixtime to remove this MySQLesque logic? // TODO: Use unixtime to remove this MySQLesque logic?
_, err := qgen.NewAcc().Update("polls_votes").Set("ipaddress='0'").DateOlderThan("castAt", c.Config.PollIPCutoff, "day").Where("ipaddress!='0'").Exec() _, err := qgen.NewAcc().Update("polls_votes").Set("ipaddress='0'").DateOlderThan("castAt", c.Config.PollIPCutoff, "day").Where("ipaddress!='0'").Exec()
if err != nil { if err != nil {