diff options
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r-- | xmpp/gateway/gateway.go | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go index daa8f8a..d309ade 100644 --- a/xmpp/gateway/gateway.go +++ b/xmpp/gateway/gateway.go @@ -13,6 +13,11 @@ import ( "gosrc.io/xmpp/stanza" ) +type Reply struct { + Author string + Id string +} + const NSNick string = "http://jabber.org/protocol/nick" // Queue stores presences to send later @@ -27,16 +32,26 @@ var Jid *stanza.Jid var DirtySessions = false // SendMessage creates and sends a message stanza -func SendMessage(to string, from string, body string, id string, component *xmpp.Component) { - sendMessageWrapper(to, from, body, id, component, "") +func SendMessage(to string, from string, body string, id string, component *xmpp.Component, reply *Reply) { + sendMessageWrapper(to, from, body, id, component, reply, "") +} + +// SendServiceMessage creates and sends a simple message stanza from transport +func SendServiceMessage(to string, body string, component *xmpp.Component) { + sendMessageWrapper(to, "", body, "", component, nil, "") +} + +// SendTextMessage creates and sends a simple message stanza +func SendTextMessage(to string, from string, body string, component *xmpp.Component) { + sendMessageWrapper(to, from, body, "", component, nil, "") } // SendMessageWithOOB creates and sends a message stanza with OOB URL -func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, oob string) { - sendMessageWrapper(to, from, body, id, component, oob) +func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, oob string) { + sendMessageWrapper(to, from, body, id, component, reply, oob) } -func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, oob string) { +func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, oob string) { componentJid := Jid.Full() var logFrom string @@ -69,6 +84,12 @@ func sendMessageWrapper(to string, from string, body string, id string, componen URL: oob, }) } + if reply != nil { + message.Extensions = append(message.Extensions, extensions.Reply{ + To: reply.Author, + Id: reply.Id, + }) + } sendMessage(&message, component) } |