~edwargix/tallyard

1d281b340eedf36b8118832c9c3b697a758594ae — David Florness 2 years ago 3457285
Allow disabling of message redactions
2 files changed, 13 insertions(+), 2 deletions(-)

M cmd/tallyard/main.go
M election/voter.go
M cmd/tallyard/main.go => cmd/tallyard/main.go +12 -1
@@ 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{

M election/voter.go => election/voter.go +1 -1
@@ 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()