aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-01 05:23:46 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-01 05:23:46 +0300
commitbd281385c3773002ce6130191fcaec4af6a130d1 (patch)
tree7ec824d23f8a2487fbce16d20b831eeb36af32a3
parent2bd15ce6f26687e1b7e5a84254eeb52f042719b3 (diff)
Another attempt to block unwanted auth requests
-rw-r--r--telegram/handlers.go11
1 files 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,