From 1d281b340eedf36b8118832c9c3b697a758594ae Mon Sep 17 00:00:00 2001 From: David Florness Date: Fri, 31 Dec 2021 17:41:41 -0600 Subject: [PATCH] Allow disabling of message redactions --- cmd/tallyard/main.go | 13 ++++++++++++- election/voter.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/tallyard/main.go b/cmd/tallyard/main.go index 341b350..b294908 100644 --- a/cmd/tallyard/main.go +++ b/cmd/tallyard/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "flag" "fmt" "io/ioutil" "os" @@ -22,7 +23,15 @@ import ( "tallyard.xyz/ui" ) +var noRedact bool + +func init() { + flag.BoolVar(&noRedact, "no-redact", false, "don't redact any messages once election is over (useful for debugging)") +} + func main() { + flag.Parse() + os.MkdirAll(xdg.DataHome() + "/tallyard", 0700) file, err := os.OpenFile(xdg.DataHome() + "/tallyard/tallyard.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) @@ -170,7 +179,9 @@ func main() { el.PrintResults() - el.Finish(client) + if !noRedact { + el.RedactEvents(client) + } } var electionFilter = &mautrix.Filter{ diff --git a/election/voter.go b/election/voter.go index 32549c8..9cbf541 100644 --- a/election/voter.go +++ b/election/voter.go @@ -419,7 +419,7 @@ func (el *Election) SendSum(client *mautrix.Client, eventStore *EventStore) erro return nil } -func (el *Election) Finish(client *mautrix.Client) { +func (el *Election) RedactEvents(client *mautrix.Client) { el.Lock() defer el.Save() defer el.Unlock() -- 2.38.4