EionRobb / purple-mattermost

A libpurple/Pidgin plugin for Mattermost
GNU General Public License v3.0
93 stars 23 forks source link

Bitlbee auto_join problem #125

Open edmcman opened 4 years ago

edmcman commented 4 years ago

I'm encountering a pretty annoying bug when using bitlbee. When I have a Mattermost channel set to auto_join, bitlbee joins the channel, but no one is present besides me. If I /part and /join the channel, I join a slightly differently named room. For example, if the channel is #foo, I will be joined into #foo_. In the new room, the other users in the room are actually present.

If I turn off auto_join and manually join the channel, it works as expected. I think this might be a problem where bitlbee is joining the channel before Mattermost is ready.

I am happy to look into this a little more, but it's unclear if this is a bug in purple-mattermost or bitlbee itself. Do you have any insights?

EionRobb commented 4 years ago

I've seen this happen with other prpls if the "account connected" function is called before its possible to join

If you can get a purple debug log out of bitlbee it might shed a bit more light on what's happening

edmcman commented 4 years ago

I have a debug log, but it has a lot of sensitive information, so I don't want to show it in its entirety. If there is something in particular that you think would be helpful to see I could extract it.

One thing I have noticed is that during the buggy behavior, there is not a call to purple_conversation_new, even though purple-mattermost calls serv_got_joined_chat. This makes me think it could be a bug in bitlbee. I'm very new to libpurple programming, so I'm trying to figure out how all this stuff works as I go!

edmcman commented 4 years ago

Oops, nevermind about bitlbee. I think the problem is that there is no alias at https://github.com/EionRobb/purple-mattermost/blob/master/libmattermost.c#L3687

Since alias is NULL, purple_serv_got_joined_chat bails out.

It looks like normally the aliases are computed in mm_add_channels_to_blist, but maybe for the auto join channels this is too late?

edmcman commented 4 years ago

Looks like we set the connection as connected at https://github.com/EionRobb/purple-mattermost/blob/master/libmattermost.c#L3687 which is when bitlbee starts the auto join process. But the channels are not created until mm_get_open_channels_for_team asynchronously completes.

EionRobb commented 4 years ago

Does it work ok if you move that "connected" to after the get-open-channels callback?

edmcman commented 4 years ago

Yes. The PR in #126 fixes the problem for me. I think we need to have the counter though so we know when all get-open-channels are done.