diff options
Diffstat (limited to 'connector/xmpp/xmpp.go')
-rw-r--r-- | connector/xmpp/xmpp.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go index b18e670..02d1a96 100644 --- a/connector/xmpp/xmpp.go +++ b/connector/xmpp/xmpp.go @@ -308,6 +308,19 @@ func (xm *XMPP) Leave(roomId RoomID) { } func (xm *XMPP) Send(event *Event) error { + if event.Attachments != nil && len(event.Attachments) > 0 { + for _, at := range event.Attachments { + url := at.URL() + if url == "" { + // TODO find a way to send them using some hosing of some kind + return fmt.Errorf("Attachment without URL sent to XMPP") + } else { + event.Text += fmt.Sprintf("\n%s (%s, %dkb)", + url, at.Mimetype(), at.Size()/1024) + } + } + } + fmt.Printf("xm *XMPP Send %#v\n", event) if len(event.Recipient) > 0 { _, err := xm.conn.Send(gxmpp.Chat{ |