From 6e32c62f8dac5ccc97dd0a6067965ba2689f3c86 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Fri, 3 Mar 2023 21:41:45 -0500 Subject: Assign IDs from Telegram to XMPP messages --- xmpp/gateway/gateway.go | 11 ++++++----- xmpp/handlers.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'xmpp') diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go index f4ec690..daa8f8a 100644 --- a/xmpp/gateway/gateway.go +++ b/xmpp/gateway/gateway.go @@ -27,16 +27,16 @@ var Jid *stanza.Jid var DirtySessions = false // SendMessage creates and sends a message stanza -func SendMessage(to string, from string, body string, component *xmpp.Component) { - sendMessageWrapper(to, from, body, component, "") +func SendMessage(to string, from string, body string, id string, component *xmpp.Component) { + sendMessageWrapper(to, from, body, id, component, "") } // SendMessageWithOOB creates and sends a message stanza with OOB URL -func SendMessageWithOOB(to string, from string, body string, component *xmpp.Component, oob string) { - sendMessageWrapper(to, from, body, component, oob) +func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, oob string) { + sendMessageWrapper(to, from, body, id, component, oob) } -func sendMessageWrapper(to string, from string, body string, component *xmpp.Component, oob string) { +func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, oob string) { componentJid := Jid.Full() var logFrom string @@ -59,6 +59,7 @@ func sendMessageWrapper(to string, from string, body string, component *xmpp.Com From: messageFrom, To: to, Type: "chat", + Id: id, }, Body: body, } diff --git a/xmpp/handlers.go b/xmpp/handlers.go index d5653ce..d83fef4 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -106,7 +106,7 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { if err == nil && toJid.Bare() == gatewayJid && (strings.HasPrefix(msg.Body, "/") || strings.HasPrefix(msg.Body, "!")) { response := session.ProcessTransportCommand(msg.Body, resource) if response != "" { - gateway.SendMessage(msg.From, "", response, component) + gateway.SendMessage(msg.From, "", response, "", component) } return } -- cgit v1.2.3