tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

`TdApi.GetChat` behavior #2553

Closed akulik512 closed 1 year ago

akulik512 commented 1 year ago

Hello @levlam I noticed that TdApi.GetChat request returns the 400 Exception when I use the correct chatId.

I send such a request client.send(new TdApi.GetChat(chatId), defaultHandler); to get a chat by id (chatId is correct and exists) and it returns this exception:

Error {
  code = 400
  message = "Chat not found"
}

But when I send TdApi.SearchPublicChat request to make a search by username (the chatId owns this username) it works well. So after that, I send the same request to find a channel by chatId, and it returns chat information.

I can describe this issue easier:

Or maybe it's expected behavior because I see it in TdApi.GetChat description.

Returns information about a chat by its identifier, this is an offline request if the current user is not a bot. Maybe we should find a chat by name before making a search by id to upload the chat in the cache?

akulik512 commented 1 year ago

This is expected behavior. Before requesting a chat by id the TdLib must know about this chat in the current session (link).