From bd281385c3773002ce6130191fcaec4af6a130d1 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Mon, 31 Jan 2022 21:23:46 -0500 Subject: [PATCH] Another attempt to block unwanted auth requests --- telegram/handlers.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/telegram/handlers.go b/telegram/handlers.go index 4b44463..c83f418 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -143,7 +143,8 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { c.cache.SetChat(update.Chat.Id, update.Chat) var isChannel = false - if update.Chat.Type.ChatTypeType() == client.TypeChatTypeSupergroup { + chatType := update.Chat.Type.ChatTypeType() + if chatType == client.TypeChatTypeSupergroup { typeSupergroup, ok := update.Chat.Type.(*client.ChatTypeSupergroup) if !ok { uhOh() @@ -151,7 +152,13 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { isChannel = typeSupergroup.IsChannel } - if !(isChannel && update.Chat.LastReadInboxMessageId == 0) { + // don't subscribe to channel posters + if !((isChannel && update.Chat.LastReadInboxMessageId == 0) || + // don't subscribe to chats with no conversation + // (manual adding will trigger a subscribe anyway) + (update.Chat.LastReadInboxMessageId == 0 && + update.Chat.LastReadOutboxMessageId == 0 && + chatType == client.TypeChatTypePrivate)) { gateway.SendPresence( c.xmpp, c.jid,