aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2024-01-29 12:28:15 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2024-01-29 12:28:15 +0300
commitea004b7f7c11fa0ddf560317fd9d6f9b2869144a (patch)
tree96157b08b5db8fde4088fde0cf1515be0c73bf6a /xmpp
parentc141c4ad2bebe51562be0a7cfe0671f34b0a49fb (diff)
Reflect Telegram edits natively by nativeedits option
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/gateway/gateway.go19
-rw-r--r--xmpp/handlers.go1
2 files changed, 12 insertions, 8 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index b1bcd69..736f760 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -54,23 +54,23 @@ var DirtySessions = false
var MessageOutgoingPermissionVersion = 0
// SendMessage creates and sends a message stanza
-func SendMessage(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, isCarbon, requestReceipt bool) {
- sendMessageWrapper(to, from, body, id, component, reply, nil, "", isCarbon, requestReceipt)
+func SendMessage(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, replaceId string, isCarbon, requestReceipt bool) {
+ sendMessageWrapper(to, from, body, id, component, reply, nil, "", replaceId, isCarbon, requestReceipt)
}
// SendServiceMessage creates and sends a simple message stanza from transport
func SendServiceMessage(to string, body string, component *xmpp.Component) {
- sendMessageWrapper(to, "", body, "", component, nil, nil, "", false, false)
+ sendMessageWrapper(to, "", body, "", component, nil, nil, "", "", false, false)
}
// 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, nil, "", false, false)
+ sendMessageWrapper(to, from, body, "", component, nil, nil, "", "", false, false)
}
// SendMessageWithOOB creates and sends a message stanza with OOB URL
-func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, oob string, isCarbon, requestReceipt bool) {
- sendMessageWrapper(to, from, body, id, component, reply, nil, oob, isCarbon, requestReceipt)
+func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, oob, replaceId string, isCarbon, requestReceipt bool) {
+ sendMessageWrapper(to, from, body, id, component, reply, nil, oob, replaceId, isCarbon, requestReceipt)
}
// SendMessageMarker creates and sends a message stanza with a XEP-0333 marker
@@ -78,10 +78,10 @@ func SendMessageMarker(to string, from string, component *xmpp.Component, marker
sendMessageWrapper(to, from, "", "", component, nil, &marker{
Type: markerType,
Id: markerId,
- }, "", false, false)
+ }, "", "", false, false)
}
-func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, marker *marker, oob string, isCarbon, requestReceipt bool) {
+func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, marker *marker, oob, replaceId string, isCarbon, requestReceipt bool) {
toJid, err := stanza.NewJid(to)
if err != nil {
log.WithFields(log.Fields{
@@ -153,6 +153,9 @@ func sendMessageWrapper(to string, from string, body string, id string, componen
if requestReceipt {
message.Extensions = append(message.Extensions, stanza.Markable{})
}
+ if replaceId != "" {
+ message.Extensions = append(message.Extensions, extensions.Replace{Id: replaceId})
+ }
if isCarbon {
carbonMessage := extensions.ClientMessage{
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 9caf886..8c6ba37 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -204,6 +204,7 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
err = gateway.IdsDB.Set(session.Session.Login, bare, toID, tgMessageId, msg.Id)
if err == nil {
session.AddToOutbox(msg.Id, resource)
+ session.UpdateLastChatMessageId(toID, msg.Id)
} else {
log.Errorf("Failed to save ids %v/%v %v", toID, tgMessageId, msg.Id)
}