From ef6a1a617c331c8b5b802646e575db1399563a63 Mon Sep 17 00:00:00 2001 From: Jesse Kuang Date: Tue, 15 Jan 2019 10:53:08 +0800 Subject: [PATCH] keep IQ struct unchange --- xmpp.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/xmpp.go b/xmpp.go index 57b7f06..4634e47 100644 --- a/xmpp.go +++ b/xmpp.go @@ -619,12 +619,11 @@ type Presence struct { } type IQ struct { - ID string - From string - To string - Type string - Query string - QueryName xml.Name + ID string + From string + To string + Type string + Query []byte } // Recv waits to receive the next XMPP stanza. @@ -668,8 +667,15 @@ func (c *Client) Recv() (stanza interface{}, err error) { return Chat{}, err } } - return IQ{ID: v.ID, From: v.From, To: v.To, Type: v.Type, - Query: v.Query.InnerXML, QueryName: v.Query.XMLName}, nil + if v.Query.XMLName.Local == "" { + return IQ{ID: v.ID, From: v.From, To: v.To, Type: v.Type}, nil + } else if res, err := xml.Marshal(v.Query); err != nil { + // should never occur + return Chat{}, err + } else { + return IQ{ID: v.ID, From: v.From, To: v.To, Type: v.Type, + Query: res}, nil + } } } }