mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-24 03:22:01 -08:00
easy xmlformat output
This commit is contained in:
parent
4c23014051
commit
15ceab9fc4
11
message.go
11
message.go
@ -45,12 +45,13 @@ func (messageDecoder) decode(p *xml.Decoder, se xml.StartElement) (Message, erro
|
|||||||
return packet, err
|
return packet, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Support missing element (thread, extensions) by using proper marshaller
|
// XMPPFormat with all Extensions
|
||||||
func (msg *Message) XMPPFormat() string {
|
func (msg *Message) XMPPFormat() string {
|
||||||
return fmt.Sprintf("<message to='%s' type='chat' xml:lang='en'>"+
|
out, err := xml.MarshalIndent(msg, "", "")
|
||||||
"<body>%s</body></message>",
|
if err != nil {
|
||||||
msg.To,
|
return ""
|
||||||
xmlEscape(msg.Body))
|
}
|
||||||
|
return string(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalXML implements custom parsing for IQs
|
// UnmarshalXML implements custom parsing for IQs
|
||||||
|
Loading…
Reference in New Issue
Block a user