velour / chat

An easy-to-use client for Slack, Telegram, IRC, or all at once!
7 stars 0 forks source link

telegram: User.PhotoURL doesn't always load on first message #53

Closed eaburns closed 7 years ago

eaburns commented 7 years ago

IIRc, there is a race when we don't always load the users photo on their first message. I remember thinking that it'll either never come up or will never bother me. Well, it both comes up and it bothers me.

eaburns commented 7 years ago

here's an example:

2017/01/02 20:32:54 Telegram RPC getFile map[file_id:media] failed: Bad Request: invalid file id
Message{
        ID: "1508"
        From: User{
                ID: "256030111"
                Nick: "flyngpngn"
                FullName: "flyngpngn"
                DisplayName: "flyngpngn"
                PhotoURL: "https://bridge.chrissexton.org/telegram/media"
        }
        Text: "Stk5! Where do I get it!?"
}

notice the URL without a file-id.

eaburns commented 7 years ago

Probably because we always call updateUser asynchronously. Instead, we should call it synchronously if it's the first time the user has been seen, otherwise call it asynchronously.