Revert sending carbons for outgoing messages to other resources (they duplicate what clients already send to each other)
This commit is contained in:
parent
8fc9edd7e7
commit
608f675512
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
COMMIT := $(shell git rev-parse --short HEAD)
|
COMMIT := $(shell git rev-parse --short HEAD)
|
||||||
TD_COMMIT := "8517026415e75a8eec567774072cbbbbb52376c1"
|
TD_COMMIT := "8517026415e75a8eec567774072cbbbbb52376c1"
|
||||||
VERSION := "v1.7.2"
|
VERSION := "v1.7.3"
|
||||||
MAKEOPTS := "-j4"
|
MAKEOPTS := "-j4"
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
goxmpp "gosrc.io/xmpp"
|
goxmpp "gosrc.io/xmpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version string = "1.7.2"
|
var version string = "1.7.3"
|
||||||
var commit string
|
var commit string
|
||||||
|
|
||||||
var sm *goxmpp.StreamManager
|
var sm *goxmpp.StreamManager
|
||||||
|
|
|
@ -658,7 +658,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
if messages != nil && messages.Messages != nil {
|
if messages != nil && messages.Messages != nil {
|
||||||
for _, message := range messages.Messages {
|
for _, message := range messages.Messages {
|
||||||
c.ProcessIncomingMessage(targetChatId, message, "")
|
c.ProcessIncomingMessage(targetChatId, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print vCard
|
// print vCard
|
||||||
|
|
|
@ -205,27 +205,24 @@ func (c *Client) updateChatLastMessage(update *client.UpdateChatLastMessage) {
|
||||||
func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
chatId := update.Message.ChatId
|
chatId := update.Message.ChatId
|
||||||
|
|
||||||
c.SendMessageLock.Lock()
|
|
||||||
c.SendMessageLock.Unlock()
|
|
||||||
xmppId, err := gateway.IdsDB.GetByTgIds(c.Session.Login, c.jid, chatId, update.Message.Id)
|
|
||||||
var ignoredResource string
|
|
||||||
if err == nil {
|
|
||||||
ignoredResource = c.popFromOutbox(xmppId)
|
|
||||||
} else {
|
|
||||||
log.Infof("Couldn't retrieve XMPP message ids for %v, an echo may happen", update.Message.Id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// guarantee sequential message delivering per chat
|
// guarantee sequential message delivering per chat
|
||||||
lock := c.getChatMessageLock(chatId)
|
lock := c.getChatMessageLock(chatId)
|
||||||
go func() {
|
go func() {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
// ignore self outgoing messages
|
||||||
|
if update.Message.IsOutgoing &&
|
||||||
|
update.Message.SendingState != nil &&
|
||||||
|
update.Message.SendingState.MessageSendingStateType() == client.TypeMessageSendingStatePending {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"chat_id": chatId,
|
"chat_id": chatId,
|
||||||
}).Warn("New message from chat")
|
}).Warn("New message from chat")
|
||||||
|
|
||||||
c.ProcessIncomingMessage(chatId, update.Message, ignoredResource)
|
c.ProcessIncomingMessage(chatId, update.Message)
|
||||||
|
|
||||||
c.updateLastMessageHash(update.Message.ChatId, update.Message.Id, update.Message.Content)
|
c.updateLastMessageHash(update.Message.ChatId, update.Message.Id, update.Message.Content)
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -911,7 +911,7 @@ func (c *Client) ensureDownloadFile(file *client.File) *client.File {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessIncomingMessage transfers a message to XMPP side and marks it as read on Telegram side
|
// ProcessIncomingMessage transfers a message to XMPP side and marks it as read on Telegram side
|
||||||
func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message, ignoredResource string) {
|
func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
|
||||||
var isPM bool
|
var isPM bool
|
||||||
var err error
|
var err error
|
||||||
if gateway.MessageOutgoingPermission && c.Session.Carbons {
|
if gateway.MessageOutgoingPermission && c.Session.Carbons {
|
||||||
|
@ -921,13 +921,8 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isOutgoing := message.IsOutgoing
|
isCarbon := isPM && message.IsOutgoing
|
||||||
isCarbon := isPM && isOutgoing
|
jids := c.getCarbonFullJids(isCarbon, "")
|
||||||
jids := c.getCarbonFullJids(isOutgoing, ignoredResource)
|
|
||||||
if len(jids) == 0 {
|
|
||||||
log.Info("The only resource is ignored, aborting")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var text, oob, auxText string
|
var text, oob, auxText string
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,6 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
|
||||||
if err != nil {
|
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, tgMessageId, msg.Id)
|
||||||
}
|
}
|
||||||
session.AddToOutbox(msg.Id, resource)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue