ars3niy / tdlib-purple

libpurple Telegram plugin using tdlib
Other
147 stars 29 forks source link

Empathy (telepathy-haze) doesn't popup anything for authentication (Ubuntu 20.04) #177

Open khurshid-alam opened 1 year ago

khurshid-alam commented 1 year ago

There were similar issue with old telegram-purple which was fixed long ago and it was working so far.

But it doesn't work with this library.

  1. telepathy-haze working fine with other purple based libraries. skype, discord etc.

  2. If you enter phonenumber it creates /tmp/haze-o2P7OC/tdlib/ directory with same folder structure like pidgin (and tdlib/). But then it hangs as no chat window ever opens to put auth code. Auth code appears fine on mobile. As a workaround, many autheticate in pidgin and then import to empathy. It also offers to import from pidgin at beginning but it fails to import

  3. Manually coping folder used to work with old telegram-purple (into ~/.telegram-purple folder not in ~/.purple). Though what should be the folder location for this new library? ~/.tdlib, ~/.purple/tdlib(used by pidgin), ~/.local/share/telepathy/haze/tdlib (doesn't work) ? It seems base configuration path for this library is not defined.

  4. Here is log from telepathy-haze https://pastebin.ubuntu.com/p/7xkmGBYK4p/ Interesting part

    purple/telegram-tdlib-INFO: 15:36:40.282: Incoming update: ignorig ID=-1144983202
    purple/telegram-tdlib-INFO: 15:36:40.318: Incoming update
    purple/telegram-tdlib-INFO: 15:36:40.318: Incoming update: authorization state
    purple/telegram-tdlib-INFO: 15:36:40.318: Authorization state update: authentication code requested
    purple/telegram-tdlib-INFO: 15:36:40.318: Authentication success on query 5
    purple/telegram-tdlib-INFO: 15:36:40.324: Incoming update
    purple/telegram-tdlib-INFO: 15:36:40.324: Incoming update: ignorig ID=1469292078

It seems it is ignoring bot from telegram which open a chat window where you put your code.

The telepathy-haze settings doesn't offer much either image

Any idea how can I keep it using telepathy/empathy ? (It seems copying folder from pdgin (~/.purple) should work if we can find out where telepathy-haze stores data. For old telegram-purple it was ~/.telegram-purple

BenWiederhake commented 1 year ago

Do you happen to remember how it was fixed in telegram-purple? Or when exactly it was fixed?

khurshid-alam commented 1 year ago

It was allowing apparmor to give telepathy-haze write permission to ~/.telegram-purple fixed the issue. It is giving some apparmor permission here as well, mainly to gstreamer, and /sys/class/ /dev. I have added the permission but it didn't fixed the isuue here.

/etc/appamor.d/usr.lib.telepathy

# for purple telegram
/usr/lib/purple-2/*.so  mr,
/usr/share/locale/*/LC_MESSAGES/*.mo r,
/usr/share/pixmaps/pidgin/protocols/{16,32,48}/*.png r,
owner @{HOME}/.telegram-purple/ rw,
owner @{HOME}/.telegram-purple/** rw,
owner @{HOME}/{,.purple/}telegram-purple/** rw,
owner @{HOME}/.purple/** rw,
owner @{HOME}/.purple/telegram-tdlib** rw,
/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner r,
/dev r,
/dev/shm/ r,
/sys/bus/ r,
/sys/class/ r,
/etc/pulse/client.conf r,
BenWiederhake commented 1 year ago

I don't know how apparmor works, and cannot tell whether this is the right approach. Also, the directory /tmp/ is used according to the logs to store the session, but doesn't appear in the whitelist. Maybe that's a hint?

"Incoming update: ignorig ID" in that constellation only means that tdlib-purple couldn't understand some of the packets, that doesn't necessarily mean something bad. One approach would be to find out what packages tdlib is giving you?

I'm not sure how to fix it :(

There's a slim chance that just updating to 1.8.0 with this fork might fix it, but that's a shot in the dark.

khurshid-alam commented 1 year ago

I saw two major difference between old and new libraries,

  1. New library opens a seperate window (not chat window) to enter secret code (in pidgin), where old one used to open a chat window from telegram which is why it worked in both pidgin and empathy.

  2. This one simply doesn't specify any additional base configuration path. Default is ~/.purple/tdlib. Where old library did (~/.telegram-purple in addition to ~/.purple/telegram-purple/ ) So it worked from both simulteneously from pidgin and empathy.

I never signed up/logged in my multiple linux machines. I simply copied ~/.telegram-purple to other machines. For discord/matrix and other accounts which also defines base path, I simply logged in from pidgin and then copy the folder in /home/<user>/.<protocol> from ~/.purple folder. That is what suggested in various forums. And it worked .

Haze supports importing. So I will keep digging why it is failing this time.

khurshid-alam commented 1 year ago

@BenWiederhake

I made it worked !

It seems it was indeed related to base configuration path not being set. Default is ~/.purple/tdlib. But that is for pidgin. If base path is set haze can use that after reboot. See my previous comment. Old telegram-purple does set it.

As of now haze use a temprary path to store details like /tmp/haze-Aq51du. Simply copying accounts.xml, perfs.xml, status.xml and tdlib from ~/.purple to /tmp/haze-Aq51du made it worked.

The only issue is this will get deleted after reboot and I have to copy it again with simlar path. /tmp/haze/<random-code>/.

khurshid-alam commented 1 year ago

@BenWiederhake

Can we set base configuration path for this library like we did for old libarary ?

BenWiederhake commented 1 year ago

Sure, I'll be happy to merge your pull request.