]> git.giacomolli.uk - onechat/blobdiff - whatsapp.go
Let the agent keep user instructions
[onechat] / whatsapp.go
index e02e8c66242c1953091e1a85eeb78b691f9496a0..c3db573f9c8d332ab885e662fd2b6e4e07b189f5 100644 (file)
@@ -209,10 +209,10 @@ type WhatsApp struct {
 // failed first connection starts the same outage notice as a lost connection. A
 // timer in the select retries it with a doubled wait from 2 seconds to 5
 // minutes, without a retry goroutine or a wait that blocks commands or the
-// inbox. A connection, unlink, logout, pair command, or ctx end stops retries.
-// The library owns retries after a connection opens. Run returns the error of a
-// write of the log or of the state file, which stops the daemon, because then
-// messages would be lost.
+// inbox. A connection, unlink, logout, or ctx end stops retries. The library
+// owns retries after a connection opens. Run returns the error of a write of
+// the log or of the state file, which stops the daemon, because then messages
+// would be lost.
 func (w *WhatsApp) Run(ctx context.Context, l *TurnLoop, notify func(Event)) error {
        w.mutex.Lock()
        w.notify = notify
@@ -277,13 +277,13 @@ func (w *WhatsApp) Run(ctx context.Context, l *TurnLoop, notify func(Event)) err
                                return err
                        }
                case request := <-w.requests:
-                       stopRetry()
                        cancel()
                        pairing.Wait()
                        cancel = func() {}
 
                        switch {
                        case request.unlink:
+                               stopRetry()
                                err = w.unlink(ctx, l, request.answer)
                                if err != nil {
                                        return err