diff --git a/common/poll_store.go b/common/poll_store.go index 5e4feec1..298ce835 100644 --- a/common/poll_store.go +++ b/common/poll_store.go @@ -234,8 +234,11 @@ func (s *DefaultPollStore) unpackOptionsMap(rawOptions map[int]string) []PollOpt } // TODO: Use a transaction for this? -func (s *DefaultPollStore) CastVote(optionIndex int, pollID int, uid int, ipaddress string) error { - _, err := s.addVote.Exec(pollID, uid, optionIndex, ipaddress) +func (s *DefaultPollStore) CastVote(optionIndex int, pollID int, uid int, ip string) error { + if Config.DisablePollIP { + ip = "0" + } + _, err := s.addVote.Exec(pollID, uid, optionIndex, ip) if err != nil { return err } diff --git a/common/site.go b/common/site.go index de33661b..102112e2 100644 --- a/common/site.go +++ b/common/site.go @@ -97,6 +97,7 @@ type config struct { LogPruneCutoff int DisableLastIP bool + DisablePollIP bool DisableLiveTopicList bool DisableJSAntispam bool diff --git a/docs/configuration.md b/docs/configuration.md index 1942d840..b4619552 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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. -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 +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. DisableLiveTopicList - This switch allows you to disable the live topic list. Default: false diff --git a/tickloop.go b/tickloop.go index a65c99a6..3e8c8464 100644 --- a/tickloop.go +++ b/tickloop.go @@ -194,7 +194,12 @@ func dailies() { 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? _, err := qgen.NewAcc().Update("polls_votes").Set("ipaddress='0'").DateOlderThan("castAt", c.Config.PollIPCutoff, "day").Where("ipaddress!='0'").Exec() if err != nil {