Ver Fonte

Redact the qrcode when done.

The QRCode is only good for 2 minutes, so when we're done, it's done.

Fixes #24
Gary Kramlich há 3 anos atrás
pai
commit
8dda382ac3
1 ficheiros alterados com 12 adições e 1 exclusões
  1. 12 1
      bridge/commands.go

+ 12 - 1
bridge/commands.go

@@ -118,15 +118,19 @@ func (l *loginCmd) Run(g *globals) error {
 	qrChan := make(chan string)
 	qrChan := make(chan string)
 	doneChan := make(chan struct{})
 	doneChan := make(chan struct{})
 
 
+	var qrCodeEvent id.EventID
+
 	go func() {
 	go func() {
 		code := <-qrChan
 		code := <-qrChan
 
 
-		_, err := g.user.sendQRCode(g.bot, g.roomID, code)
+		resp, err := g.user.sendQRCode(g.bot, g.roomID, code)
 		if err != nil {
 		if err != nil {
 			fmt.Fprintln(g.context.Stdout, "Failed to generate the qrcode")
 			fmt.Fprintln(g.context.Stdout, "Failed to generate the qrcode")
 
 
 			return
 			return
 		}
 		}
+
+		qrCodeEvent = resp
 	}()
 	}()
 
 
 	ctx := context.Background()
 	ctx := context.Background()
@@ -140,6 +144,13 @@ func (l *loginCmd) Run(g *globals) error {
 
 
 	<-doneChan
 	<-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()
 	user, err := client.Result()
 	if err != nil {
 	if err != nil {
 		fmt.Fprintln(g.context.Stdout, "Failed to log in")
 		fmt.Fprintln(g.context.Stdout, "Failed to log in")