From 15ceab9fc4a90097e3ae613e86026ffa1460369a Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Tue, 4 Jun 2019 19:10:21 +0200 Subject: [PATCH] easy xmlformat output --- message.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/message.go b/message.go index 5b99348..2dc165c 100644 --- a/message.go +++ b/message.go @@ -45,12 +45,13 @@ func (messageDecoder) decode(p *xml.Decoder, se xml.StartElement) (Message, erro return packet, err } -// TODO: Support missing element (thread, extensions) by using proper marshaller +// XMPPFormat with all Extensions func (msg *Message) XMPPFormat() string { - return fmt.Sprintf(""+ - "%s", - msg.To, - xmlEscape(msg.Body)) + out, err := xml.MarshalIndent(msg, "", "") + if err != nil { + return "" + } + return string(out) } // UnmarshalXML implements custom parsing for IQs