kensanata / bitlbee-mastodon

A Mastodon plugin for Bitlbee
https://alexschroeder.ch/software/Bitlbee_Mastodon
GNU General Public License v2.0
30 stars 7 forks source link

determine server to connect to by parsing username at account creation #40

Closed velartrill closed 5 years ago

velartrill commented 5 years ago

the primary purpose of this PR is to address #36 from a UI perspective and make account creation behave as expected. it does this by attempting to decode the "username" passed at account creation as a fediverse handle (either in the Mastodon @user@instance format or the pleroma user@instance format), and setting the base_url and username fields appropriately. if there is no @ sign after the username portion of the handle, we assume the user is connecting to the flagship mastodon instance https://mastodon.social, which is kind of awful but unfortunately the bitlbee plugin API does not appear to give us a way to abort the account creation and signal an error to the user.

this PR also resolves a number of compiler warnings:

kensanata commented 5 years ago

Feel free to submit another PR to add yourself as author and copyholder where you feel it is appropriate. :)

kensanata commented 5 years ago

I'm also interested in hearing what you think of c1f5d47 and 442f386.

kensanata commented 5 years ago

"i promise i can explain." Hahaha!

kensanata commented 5 years ago

I guess you wrote it partially resolves #38 and GitHub decided that this meant it actually resolved 38 so if you think there's something missing you'll have to reopen that issue again?

velartrill commented 5 years ago

bitlbee-mastodon now fully compiles on freebsd at least provided gsed and gmake are installed and gmake is used instead of make to build the library. i'd be comfortable closing this if we add a note to README.md about this dependency, though it might be better to see if we can remove the extension use trivially. i'll take a poke at that and see what it involves.

velartrill commented 5 years ago

oh, and regarding ownership: i'm fine with just assigning the copyright over to you; it doesn't seem worth complicating the project's IP situation over a relatively trivial bit of code :)

kensanata commented 5 years ago

I just compiled. I have two accounts. The first one is on octodon.social and since the default URL got changed, I can no longer log in as the default was changed to mastodon.social. I'm not sure too many people use the plugin but this is a surprising change.

velartrill commented 5 years ago

that's alarming. the only function i really touched was mastodon_init - is this called from any places besides the account add routine?

i just checked my bitlbee server and it seems to have no problem handling two accounts at a time with different servers - if you'd like to poke at it and see if the behavior is different from your server, let me know. i'd hate if this was OS-dependent somehow

kensanata commented 5 years ago

I guess it was used here.

kensanata commented 5 years ago

9a4f750 changes the default back to octodon.social

a54e0cf uses g_strdup to get the username into settings. Can you verify that it works for you? I tested it for two variants and it seems to work for me.

kensanata commented 5 years ago

As for the README: there are already mentions of NetBSD, FreeBSD and *BSD. Can you look it over and just submit the changes you want to make for the build tools?

velartrill commented 5 years ago

ohhhh i think i may know what the problem here is. when i was looking at the source for set_setstr() i noticed that bitlbee doesn't actually store values when they are equivalent to the default - it just marks the setting as "default value." in other words, the problem should only occur for octodon.social users, and only ones who are upgrading to the new plugin. those who add accounts with the new method will not be affected.

yes, the readme mentions the BSDs, but iirc only to say where the binary packages are in the repos. i'll add some documentation of the build process.

there's no point in testing a54e0cf; it needs to be reverted, as it creates a memory leak and has no positive effects. g_strdup() allocates the string on the heap (which is additionally slower than the method i used). there is a reason i wrote it the way i did. additionally, as this behavior is caused by a bug in a library we rely on, the explanatory comment needs to remain - the behavior simply looks like a mistake otherwise and any reasonable coder would refactor the g_strdup() call into a simple pointer pass, which only introduces subtle bugs in one particular codepath, meaning the bug would likely go unnoticed for some time.

velartrill commented 5 years ago

絵 🙃

i'll remove the code that produces this

kensanata commented 5 years ago

Yeah, that message should have been removed. :)