-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Improve compatibility with spectrum2 #5
Comments
Nice. The QR code is supposed to be shown as an image within an instant message flagged as a system message. It looks like system messages are ignored in your set-up. Can you configure spectrum2 to consider all messages? Alternatively, try to change libgowhatsapp.c, line 135 from
to
. |
yep. that is what I thought . //Ignore system messages as those are normally not true messages in the XMPP sense
if (flags & PURPLE_MESSAGE_SYSTEM) {
LOG4CXX_DEBUG(logger, "conv_write_im(): ignoring a system message");
return;
} this is not configurable, and changing it will have system wide effect. |
changed line you suggested now i getting these messages : 20445: 2019-03-27 17:30:11,792 INFO backend: Creating account with name '[email protected]' and protocol 'prpl-hehoe-gowhatsapp'
20445: 2019-03-27 17:30:11,792 INFO libpurple: account:Connecting to account [email protected].
20445: 2019-03-27 17:30:11,792 INFO libpurple: connection:Connecting. gc = 0x1a440c0
20445: 2019-03-27 17:30:12,752 INFO libpurple: gowhatsapp:Recieved: at 0 id remote [email protected] sender (fromMe 0)
20445: 2019-03-27 17:30:12,752 INFO backend: conv_write_im()
20445: 2019-03-27 17:30:12,752 ERROR backend: GLib g_string_free: assertion 'string != NULL' failed
20445: 2019-03-27 17:30:12,752 INFO backend: Received message body='Scan this QR code within 20 seconds to log in.' xhtml='' name='[email protected]' and still no qr shown. |
just to ensure , that this is not due to some client side limitations of displaying messages, below is a dump of incoming traffic : <message from="login\[email protected]/bot" type="chat" to="***masked***@im.domain">
<body>Scan this QR code within 20 seconds to log in.</body>
</message>
<r xmlns="urn:xmpp:sm:3"/>
<message from="login\[email protected]/bot" type="chat" to="***masked***@im.domain">
<body>Scan this QR code within 20 seconds to log in.</body>
</message>
<r xmlns="urn:xmpp:sm:3"/>
<a xmlns="urn:xmpp:sm:3" h="135"/>
<a xmlns="urn:xmpp:sm:3" h="75"/>
<message from="login\[email protected]/bot" type="chat" to="***masked***@im.domain">
<body>Scan this QR code within 20 seconds to log in.</body>
</message>
<r xmlns="urn:xmpp:sm:3"/>
<message from="whatsapp.im.domain" type="chat" to="***masked***@im.domain">
<body>error during login: qr code scan timed out
</body>
<spectrumerror xmlns="http://spectrum.im/error" error="0">CONNECTION_ERROR_NETWORK_ERROR</spectrumerror>
</message>
<presence from="whatsapp.im.domain" type="unavailable" to="***masked***@im.domain"/> thanks |
spectrum2 has.... issues with inline images. |
tried.
but this is more related to spectrum2 I assume. |
@EionRobb Is there a different, more spectrum2-compatible way of handling images in libpurple? I used the first example I came across. @evgenyh For a really dirty "solution", you can replace the body of the anonymous goroutine at purplegwa.go, line 297 with something like
. Instead of forwarding to the client, the server will store the image containing the QR code on its local filesystem. Assuming you have access and can open the image quickly enough, you should be able to login. I probably do not need to point out that this will lead to confusion if used with multiple connections at the same time. |
@hoehermann thanks for reply, I'll try that. At least for confirming if it working. |
@hoehermann the "most compatible" way is to use the libpurple request api. This has been used by other prpls for showing captcha images and getting the user to fill in the letters or whatever. Oh, maybe the notify api would be better since there's no human input required. Unfortunately, the way spectrum2 has been written, it has protocol-specific code to handle each of these request/notify api calls Using the inline image system with the http image server, spectrum will save the qrcode to disk for its web server to provide, which is similar as what you're suggesting. Unfortunately again, getting the web server to work is finnicky, and I've only heard of one person who got it working. |
Thank you both for your input. As far as I understood, the alternatives offer some, but no vast improvement over the current implementation. Consequently, I leave this as enhancement for later / maybe. |
this works. a bit unusable though |
I did not expect it to be any better. I do not use spectrum2, so… Pull requests are welcome. ;) |
golang is not my area of expertise, but will try to do my best :) |
I never worked with go before, either. Takes a bit to get used to, but it seems solid. This particular problem is probably tackled in the C part, though. It is just a hunch. The QR code is displayed with the same technique as a normal image message. Whatever solution is found – it should pave the road for both use-cases. |
I've been testing this, and image inlining works well for me, once the "http image server" is set up correctly. Modifying libgowhatsapp.c:135 as suggested, I can see the QR code in my chat (tested with gajim), and complete the login successfully. The real problem that needs a fix is another one though. Apparently, for every image message received, both Spectrum 2 and this plugin try to free the memory containing image data, and this results in a crash of the Spectrum 2 component, and a loss of the whatsapp web session as a consequence. Who should be responsible for freeing the memory containing the image data? |
From https://developer.pidgin.im/doxygen/2.7.11/html/imgstore_8h.html#6e992b86c90965143d380c9454132749
|
My bad. Thanks for reporting @rogora and thank you for your help Eion. |
Hey, did anyone get this running with spectrum2 now and if so can he advice a friend of mine how to do it quickly? Actually I'm blind, so I can not really use the original whatsApp in an productive manner. However, since before 2 weeks I was using whapp-irc, which is now broken and I can not reach the maintainer. Thus, now, I'm pretty much fucked and desperately seeking a solution. A friend of mine is operating an XMPP-server, also for my domain, and he also has spectrum so if he gets adviced, he could implement this for me. Hoehermann do you have still interest in completing this? Actually I would at least also need the possibility to receive voice messages as audiofiles. I don't care whether as link or as XMPP Filetransfer. Even without that it would be a big help for the short run, and on the long run I could also pull out my paypal if everything finally works out. |
Hi @XP-Fan. I wanted to add support for media messages anyway. Due to your request, I figured I could do so today. Hand-tailored for you, there now is a new branch. I also uploaded a binary for your convenience. Files are downloaded into the "purple home directory" – whatever that means for spectrum2. It works for me in Pidgin. The downloaded files are displayed as local file links. Some kind of translation probably needs to be done for use with spectrum2. Report back in case you need adjustments. Please note that this version was quickly thrown together and not well tested. |
Hi, at first, many thanks for wanting to help me! Unfortunately we do have one more severe problem now: The friend I mentioned is using an docker-image of spectrum, where libpurple is within. I did not know that and I personally do not have any experience with XMPP-servers and stuff, not even with linux. I do have Fedora running on an computestick, so maybe you're willing to help me make it work there over SSH? Or you could prepare everything within another docker container which he would just have to fire up and give ports to it? Dunno whether 2 instances of spectrum could connect to the same XMPP-Server, but if yes, that might also be a possibility? But if you do so, indeed, an HTTP-Server would be great for the files and the QR-Code…
|
Please note that I have no experience with spectrum2 whatsoever. I do not know if the path you are currently trying is the easiest – it sure sounds complicated to me. I do not know how your blindness affects your ability to use a computer, but you might want to check out Finch. It can be controlled by using only the keyboard, it natively supports purple-gowhatsapp and there even is a text-to-speech plug-in. Apart from that, I am not up for administering other people's systems. I am sorry. |
Well, I was talking with someone from the spectrum team, he sais it's rather easy to integrate your plugin into the docker-image, so I've just gotta wait till he finishes I suppose. As for Finch, I would be interested in that, but unfortunately it seems not to be available on Windows?
|
I do not like the prospect of publishing this plug-in in that manner, but I'll put up with that, I guess. Who did you speak to? In case of a co-operation, I'd rather not play Chinese Whispers. Indeed, Finch is only available for Linux-like systems. |
|
@thundergreen There is an option for spectrum compatibility. Please set "system-messages-are-ordinary-messages" to true. I want to add that to the readme. The plug-in will then generate an image containing the QR for log-in and saves it into a file. With spectrum, the file location is |
@hoehermann sorry for dumb question but where ? in the whatsapp.cfg? |
Aha, could be it. In the previous version the room list would be populated when the contact list was refreshed and/or when messages are received. During list refresh, it would check if the contact was a group chat JID and add it if needed. Code here. If whatsmeow doesn't deliver group chats as part of the main contact list, this could be a reason they're not showing up. I checked again. The group chat that is showing for me is the one i'm using with myself to test. I guess it gets added when the messages come through. Code here (the |
Hello I'm following this discussion a bit and was wondering how to set it up on spectrum2 but docker .. I've the feeling the docker image has not the right branch / repo? @vitalyster are you sure U added the right repo/branch/ commit to the docker file? And would you or someone mind sharing the config for that? My spectrum2 won't start the transport somehow. I've also Facebook configured and it shows up in gajim but for WhatsApp transport it shows NO underneath. I'm running prosody nightly builds (without docker) and use standard port for components .is there something I have to take care of in addition? Like discovery or something? Thanks for your help |
@thundergreen please don't discuss unrelated issues there :) Use chatroom or create a new discussion on spectrum repo - https://github.com/SpectrumIM/spectrum2/discussions |
On BitlBee, my feeling on group chats is that it's basically fine except that the whatsmeow version isn't getting an initial contact list for some reason (even with |
@vitalyster I have been working on the group chats / room list features. Since many compatibility options are the same for spectrum and bitlbee, I renamed the setting name "spectrum-compatibility" to "bridge-compatibility". |
In the past two weeks, I have not received any reports about severe defects. Is there any issue I forgot about? Especially in regard to spectrum? The section about known issues lists the issues I know of but do not want to tackle right now. If there are no critical show-stoppers, I want to make the whatsmeow branch the main branch and officially deprecate the old gowhatsapp branch. |
There are a lot of questionable decisions under "bridge-compatibility" and other options, I'm pretty sure options are not needed at all, but it can be discussed later, right now there is no reason to keep old version and need to move forward |
@vitalyster can you please pm me to troubleshoot my issue getting started with spectrum2? Also via xmpp if you want ;) I'm really interested to use and test |
Thank you for the feedback, it is very constructive. :)
Please elaborate which decisions are sub-optimal in the spectrum context. Would more finely grained options be better? |
Sorry for the necromancy but those looking for a message transport / bridge that seems to be working with whatsapp to some extend: https://sr.ht/~nicoco/slidge/ |
@petermolnar First of all, I do not consider this necromancy since the issue is still open. Some work needs to be done, but most features including group chats and file transfer are good to go (most of the time). ;) Thank you for the suggestion. I noticed slidge and its WhatsApp support. In 2023, it did not support group chats. A feature crucial to many users. But it has matured very well over the past months. For the record, there is also https://maunium.net/go/mautrix-whatsapp/ with mautrix offering feature-complete bridges to many other protocols, too. |
User reports indicate that Spectrum currently does not properly forward the message containing the QR-code. This is a show-stopper, but I am booked. I hope I can look into this in March. Update: This turned out to be a usage issue. The user had blocked unsolicited messages – including Spectrum's "Logon QR Code" user. |
I just setup gowhatsapp successfully. I had the webserver for images set up, so receiving images via other protocols works already. I'm sharing what I did in case others are stuck (maybe add a spectrum2 section to the README?). Replace "yourdomain.com" with your XMPP server's domain:
|
I'd recommend you keep the read receipts set to"on-answer", otherwise it will render the WhatsApp client on your phone useless as you'll never see a push again. Also you might want to set "group-is-file-origin" to false or else voice messages you receive in groups will end up showing as local paths whose you cannot open if your XMPP client isn't on the same computer where you run the rest. Anything I forgot?
|
In my case that's intentional. I use a XMMP client on my phone to aggregate all messaging apps.
I edited both changes in my original comment. Thanks for mentioning it. |
We run the transport on the latest Spectrum docker image on our server (jabber.hot-chilli.net) with the following purple options:
My guess is that some of these options are default now. We (including @hoehermann and @theassemblerguy) are doctoring on the service for quite a while now. :-) |
I think this option (now default?) should also include "on-interact" behavior. Some XMPP clients are able to send "interaction" events (which is mapped to "conversation-updated" signal on libpurple side). So - when we receive "conversation-updated" event we mark as read and also mark as read on answer, that should make happy both great and non-great XMPP clients. Does it work? |
@heeplr Thank you for posting the instructions and sharing your configuration. This makes me more open to setting up Spectrum for testing purposes. Up to now, I failed to build the dependencies since I never worked with scons. vitalyster kindly has prepared a build for us. I want to check it out next. @msebald It is good having you on board. |
That is a very nice feature. Thank you for pointing that out. Unfortunately, the "conversation-updated" is a bit weird on Pidgin: It is also fired upon arrival of new messages. I guess this is due to "appending a new message" means the "conversation has been updated". A reasonable interpretation, but also ambiguous. And – for our goals – detrimental. Currently, I check Pidgin-specific values in particular: https://github.com/hoehermann/purple-gowhatsapp/blob/60b7398/src/c/receipt.c#L16 Once I managed to set-up a local Spectrum instance for testing purposes, I want to investigate possibilities to make this work. @vitalyster Which XMPP client does sent "interaction" events? That would be useful for debugging. The Pidgin code does not mention "interaction" as a string. |
@hoehermann spectrum uses "unseen_count" not "unseen-count": https://github.com/SpectrumIM/spectrum2/blob/86fb98344fe6780afcbf5d4514caa6792be5c9fc/backends/libpurple/main.cpp#L710 |
Checked the Pidgin code and it seems the bug on our side, will fix it shortly |
I really recommend using it if there is even a remote chance to have some box running 24/7 (raspberry pi or something). Having only one IM App for everything on mobile (Conversations in my case) really is a breeze. |
I hope you folks do not mind me turning this into a "help hoehermann to get spectrum2 running" discussion. @heeplr I would be glad if you could help me out. It is a public holiday so I used the time to try again, but got stuck on step 5. 🙁 I set-up a clean install of Debian 12 (bookworm). I successfully (I think) set-up prosody. I had I tried following the instructions, but allegedly using
And I adjusted
I created a user manually:
I tried to install spectrum2:
In 2023, that failed in the configuration step because spectrum_manager was missing configuration files. I found it quite odd I need to prepare the configuration before even installing the software. From the documentation I could infer I need a file at Spectrum2 still would not start because there seemed some disagreement on which user should be used. The documentation said "spectrum", however the systemd unit installed at I then proceeded and added the Unfortunately, started with Reading through the code, I found out that this output is not acutally produced by Now
So… what do I now? How do I actually use Spectrum? What is the "service discovery"? |
I'm not 100% sure, but I could imagine that "localhost" could impose problems. It might work for testing but I doubt you can use prosody for real XMPP use cases without a VirtualHost with a FQDN.
That's very odd. I don't use debian so I'm not of much help here. I suggest you join [email protected] MUC to get help (and moan about the suboptimal spectrum2 docs, which I also experienced).
Odd that it wants to run as root. But it seems you fixed it.
Again, not sure if this can ever work. If you own a domain, you could use a subdomain. e.g. im.example.com for prosody and whatsapp.im.example.com for your transport. They all need valid SSL certs (e.g. letsencrypt)
You could try the strace tool to find, which file it's trying to open.
Yeah, that sounds like a bug. There should be log output.
Indeed, but that's your smallest problem.
Sounds like you're up & running. Assuming everything works, you can now connect to your prosody server using pidgin (or any XMPP client). In pidgin you need the "XMPP Service Discovery" plugin. When you activate it, do:
Hope that helps. |
Spectrum was created few years before systemd ;) Actually the whole
|
Thank you for your help. With your combined efforts, I was able to get Spectrum (with Prosody and Apache) up and running. Here are the things I learned: Client
SpectrumUsing it for the first time, I learned much about Spectrum and how it handles MUCs in particular. I had assumed that Spectrum just forwards the JIDs and leaves "JID→friendly-name" look-up to the client. While in fact, Spectrum does some translation on the server side. In Pidgin, the user can call I now reorganized the connection procedure so the connection is only marked as "connected" after the contacts have been fetched. Group chat participant lists now seem to be populated with friendly names. Continuing from hereI want to wait two weeks so the bitlbee users can notify me of regressions. I also want to do some tests myself. |
trying to get this plugin to work with spectrum2 libpurple backend
"error during login: qr code scan timed out"
P.S> maybe I'm doing something wrong.
thanks
piece from log :
thanks
The text was updated successfully, but these errors were encountered: