Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot unmarshal object into Go struct field .last_message of type tdlib.MessageSender #97

Open
KaoriEl opened this issue Dec 7, 2021 · 0 comments

Comments

@KaoriEl
Copy link

KaoriEl commented Dec 7, 2021

I am using the second version of the library, and when receiving all the user's chats, this error constantly drops, does anyone know how to fix it?
json: cannot unmarshal object into Go struct field .last_message of type tdlib.MessageSender

func getChatList(client *client.Client, limit int) ([]*tdlib.Chat, error) {

var allChats []*tdlib.Chat

var chatList = tdlib.NewChatListMain()

var chats, getChatsErr = client.GetChats(chatList, int32(limit))
if getChatsErr != nil {
	return nil, getChatsErr
}

for len(chats.ChatIDs) > limit {
	// get chats (ids) from tdlib
	_, err := client.LoadChats(chatList, int32(limit-len(chats.ChatIDs)))
	if err != nil {
		if err.(tdlib.RequestError).Code != 404 {
			chats, err = client.GetChats(chatList, int32(limit))
			break
		}
		return nil, err
	}

	chats, err = client.GetChats(chatList, int32(limit))
}

if len(chats.ChatIDs) == 0 {
	return allChats, nil
}

for _, chatID := range chats.ChatIDs {
	// get chat info from tdlib
	var chat, getChatErr = client.GetChat(chatID)
	if getChatErr == nil {
		allChats = append(allChats, chat)
	} else {
		return nil, getChatErr
	}
}


return allChats, nil

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant