aboutsummaryrefslogtreecommitdiff
path: root/xmpp/gateway/gateway.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-03-05 11:00:53 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-03-05 11:00:53 +0300
commit4a5b83dff5c568871d5624202e2ee27e5d0de242 (patch)
tree05360ccd21770b830c29ebaacf6ef00787ad1a68 /xmpp/gateway/gateway.go
parent6e32c62f8dac5ccc97dd0a6067965ba2689f3c86 (diff)
Show XEP-0461 replies from Telegram
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r--xmpp/gateway/gateway.go31
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)
}