aboutsummaryrefslogtreecommitdiff
path: root/telegram
diff options
context:
space:
mode:
Diffstat (limited to 'telegram')
-rw-r--r--telegram/commands.go2
-rw-r--r--telegram/handlers.go19
-rw-r--r--telegram/utils.go11
3 files changed, 12 insertions, 20 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index e164ce1..206e049 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -658,7 +658,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
if messages != nil && messages.Messages != nil {
for _, message := range messages.Messages {
- c.ProcessIncomingMessage(targetChatId, message, "")
+ c.ProcessIncomingMessage(targetChatId, message)
}
}
// print vCard
diff --git a/telegram/handlers.go b/telegram/handlers.go
index cedea63..0d1cda9 100644
--- a/telegram/handlers.go
+++ b/telegram/handlers.go
@@ -205,27 +205,24 @@ func (c *Client) updateChatLastMessage(update *client.UpdateChatLastMessage) {
func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
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
lock := c.getChatMessageLock(chatId)
go func() {
lock.Lock()
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{
"chat_id": chatId,
}).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)
}()
diff --git a/telegram/utils.go b/telegram/utils.go
index cd25c22..62ce945 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -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
-func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message, ignoredResource string) {
+func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
var isPM bool
var err error
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 && isOutgoing
- jids := c.getCarbonFullJids(isOutgoing, ignoredResource)
- if len(jids) == 0 {
- log.Info("The only resource is ignored, aborting")
- return
- }
+ isCarbon := isPM && message.IsOutgoing
+ jids := c.getCarbonFullJids(isCarbon, "")
var text, oob, auxText string