aboutsummaryrefslogtreecommitdiff
path: root/connector/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'connector/xmpp')
-rw-r--r--connector/xmpp/xmpp.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go
index dcf1db6..efaaf64 100644
--- a/connector/xmpp/xmpp.go
+++ b/connector/xmpp/xmpp.go
@@ -306,13 +306,13 @@ func (xm *XMPP) Leave(roomId RoomID) {
xm.conn.LeaveMUC(string(roomId))
}
-func (xm *XMPP) Send(event *Event) error {
+func (xm *XMPP) Send(event *Event) (string, 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")
+ return "", fmt.Errorf("Attachment without URL sent to XMPP")
} else {
event.Text += fmt.Sprintf("\n%s (%s, %dkb)",
url, at.Mimetype(), at.Size()/1024)
@@ -320,6 +320,10 @@ func (xm *XMPP) Send(event *Event) error {
}
}
+ if event.Id == "" {
+ event.Id = xid.New().String()
+ }
+
log.Tracef("xm *XMPP Send %#v\n", event)
if len(event.Recipient) > 0 {
_, err := xm.conn.Send(gxmpp.Chat{
@@ -327,20 +331,17 @@ func (xm *XMPP) Send(event *Event) error {
Remote: string(event.Recipient),
Text: event.Text,
})
- return err
+ return event.Id, err
} else if len(event.Room) > 0 {
- if event.Id == "" {
- event.Id = xid.New().String()
- }
_, err := xm.conn.Send(gxmpp.Chat{
Type: "groupchat",
Remote: string(event.Room),
Text: event.Text,
ID: event.Id,
})
- return err
+ return event.Id, err
} else {
- return fmt.Errorf("Invalid event")
+ return "", fmt.Errorf("Invalid event")
}
}