~samwhited/xmpp

473b6ee63dc89c27e9f83e2ff74395fc45fec7df — Sam Whited 3 months ago 9e16771
xmpp: fix stanza error reply association

Previously we would try to track presence or message stanzas of types
other than error, even though they would never match an ID in the
tracked stanzas. This didn't cause problems, it was just an extra check.

Signed-off-by: Sam Whited <sam@samwhited.com>
1 files changed, 2 insertions(+), 2 deletions(-)

M session.go
M session.go => session.go +2 -2
@@ 538,9 538,8 @@ func handleInputStream(s *Session, handler Handler) (err error) {

	iqOk := isIQ(start.Name)
	_, _, id, typ := getIDTyp(start.Attr)
	iqNeedsResp := typ == string(stanza.GetIQ) || typ == string(stanza.SetIQ)

	if !iqNeedsResp {
	if typ == string(stanza.ResultIQ) || typ == "error" {
		s.sentIQMutex.Lock()
		c := s.sentIQs[id]
		s.sentIQMutex.Unlock()


@@ 571,6 570,7 @@ func handleInputStream(s *Session, handler Handler) (err error) {
		return err
	}

	iqNeedsResp := typ == string(stanza.GetIQ) || typ == string(stanza.SetIQ)
	// If the user did not write a response to an IQ, send a default one.
	if iqOk && iqNeedsResp && !rw.wroteResp {
		_, toAttr := attr.Get(start.Attr, "to")