~edwargix/tallyard

0dae71afe65ca97de7d3e539975dd6e1a61b9d5e — David Florness 3 years ago 1d281b3
Log uploads to file

So that homeserver admins can know which media files that tallyard uploads can
be deleted.
2 files changed, 24 insertions(+), 0 deletions(-)

A election/utils.go
M election/voter.go
A election/utils.go => election/utils.go +22 -0
@@ 0,0 1,22 @@
package election

import (
	"fmt"
	"os"
	"time"

	"github.com/kyoh86/xdg"
	log "github.com/sirupsen/logrus"
	"maunium.net/go/mautrix/id"
)

func LogUpload(contentURI id.ContentURI) {
	file, err := os.OpenFile(xdg.DataHome() + "/tallyard/uploads.tsv", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
	if err != nil {
		log.Warnf("couldn't open uploads file: %s", err)
		return
	}
	defer file.Close()
	t, _ := time.Now().UTC().MarshalText()
	fmt.Fprintf(file, "%s\t%s\n", string(t), contentURI.String())
}

M election/voter.go => election/voter.go +2 -0
@@ 191,6 191,7 @@ func (el *Election) SendProvingKeys(client *mautrix.Client, eventStore *EventSto
		if err != nil {
			return fmt.Errorf("couldn't upload eval proving key: %s", err)
		}
		LogUpload(uploadResp.ContentURI)
		evalProvingKeyURI = uploadResp.ContentURI
	}



@@ 222,6 223,7 @@ func (el *Election) SendProvingKeys(client *mautrix.Client, eventStore *EventSto
		if err != nil {
			return fmt.Errorf("couldn't upload sum proving key: %s", err)
		}
		LogUpload(uploadResp.ContentURI)
		sumProvingKeyURI = uploadResp.ContentURI
	}