aboutsummaryrefslogtreecommitdiff
path: root/xmpp/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r--xmpp/handlers.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index cfa6226..3443573 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -197,8 +197,8 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
session.SendMessageLock.Lock()
defer session.SendMessageLock.Unlock()
- tgMessageId := session.ProcessOutgoingMessage(toID, text, msg.From, replyId, replaceId)
- if tgMessageId != 0 {
+ tgMessage := session.ProcessOutgoingMessage(toID, text, msg.From, replyId, replaceId)
+ if tgMessage != nil {
if replaceId != 0 {
// not needed (is it persistent among clients though?)
/* err = gateway.IdsDB.ReplaceIdPair(session.Session.Login, bare, replace.Id, msg.Id, tgMessageId)
@@ -207,9 +207,24 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
} */
session.AddToOutbox(replace.Id, resource)
} else {
- err = gateway.IdsDB.Set(session.Session.Login, bare, toID, tgMessageId, msg.Id)
+ err = gateway.IdsDB.Set(session.Session.Login, bare, toID, tgMessage.Id, msg.Id)
if err != nil {
- log.Errorf("Failed to save ids %v/%v %v", toID, tgMessageId, msg.Id)
+ log.Errorf("Failed to save ids %v/%v %v", toID, tgMessage.Id, msg.Id)
+ }
+ }
+
+ // pong groupchat messages back
+ if msg.Type == "groupchat" {
+ toJid, err := stanza.NewJid(msg.To)
+ if err == nil && toJid.Resource == "" {
+ session.SendMessageToGateway(
+ toID,
+ tgMessage,
+ msg.Id,
+ false,
+ msg.To + "/" + session.GetMUCNickname(session.GetSenderId(tgMessage)),
+ []string{msg.From},
+ )
}
}
} else {