From 8dda382ac32e607201893fb5132b7f1c4b96300a Mon Sep 17 00:00:00 2001 From: Gary Kramlich Date: Thu, 7 Apr 2022 14:03:05 -0500 Subject: [PATCH] Redact the qrcode when done. The QRCode is only good for 2 minutes, so when we're done, it's done. Fixes #24 --- bridge/commands.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bridge/commands.go b/bridge/commands.go index 69993eb..e58516e 100644 --- a/bridge/commands.go +++ b/bridge/commands.go @@ -118,15 +118,19 @@ func (l *loginCmd) Run(g *globals) error { qrChan := make(chan string) doneChan := make(chan struct{}) + var qrCodeEvent id.EventID + go func() { code := <-qrChan - _, err := g.user.sendQRCode(g.bot, g.roomID, code) + resp, err := g.user.sendQRCode(g.bot, g.roomID, code) if err != nil { fmt.Fprintln(g.context.Stdout, "Failed to generate the qrcode") return } + + qrCodeEvent = resp }() ctx := context.Background() @@ -140,6 +144,13 @@ func (l *loginCmd) Run(g *globals) error { <-doneChan + if qrCodeEvent != "" { + _, err := g.bot.RedactEvent(g.roomID, qrCodeEvent) + if err != nil { + fmt.Errorf("Failed to redact the qrcode: %v", err) + } + } + user, err := client.Result() if err != nil { fmt.Fprintln(g.context.Stdout, "Failed to log in")