Another attempt to block unwanted auth requests

This commit is contained in:
Bohdan Horbeshko 2022-01-31 21:23:46 -05:00
parent 2bd15ce6f2
commit bd281385c3

View file

@ -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,