johanw666 / Signal-Android

Fork from a private messenger for Android with extra options added: full backup and (partial, ony text) xml backup of messages. Restore can happen at any time, not only after a fresh install. Import SMS database. Import of (unencrypted) WhatsApp databases. Removed apk expire. Choose between passphrase protection and the Android screenlock. Choice for the backup location (internal or removable storage on Android < 11 (on 11 and higher this is already possible)). Set the maptype in the place picker. Option to treat view-once media as normal media. Option to ignore remote deletion. Choose between FCM or websocket notification delivery.
https://johanw.home.xs4all.nl/Signal/signal-jw.html
GNU Affero General Public License v3.0
245 stars 16 forks source link

Importing WhatsApp group chats without their participants #49

Open Terrance opened 2 years ago

Terrance commented 2 years ago

(I'm not sure if this is the right place to ask as the WhatsApp import stuff appears to be across two other forks, but it's present in the build from this repo so is presumably being maintained in some capacity here.)

I've got a handful of WhatsApp groups who have since moved to platforms other than WhatsApp and Signal, but I'd like to keep a copy of the message history in Signal. I created empty groups matching the names of these groups, and the import option correctly matches them up, but only my own messages are imported -- presumably this is because the other participants are not in the group. Is there a way to get their past messages imported too, without adding them to my copy of the Signal chats?

johanw666 commented 2 years ago

I didn't write that code so I'd have to look at that, but I will have to have it updated anyway now that WhatsApp introduced reactions too.

Terrance commented 4 months ago

Did this get anywhere by the way? I recently had to crack open my backup WhatsApp database in order to find a message from an old group chat, so I'd still be interested in importing these to Signal.

At a guess, it's to do with the recipient resolution here:

https://github.com/johanw666/Signal-Android/blob/99b18498027917f85aaec42ba60e139e43700e02/app/src/main/java/org/thoughtcrime/securesms/database/WhatsappBackupImporter.java#L167

From digging a few layers deeper, I can't see it trying to create new recipients during group import, only resolve existing ones.

johanw666 commented 4 months ago

I can take a look but to be honest I have no time to maintain this import function at the moment. It could very well not work due to a changed WhatsApp database structure.

Terrance commented 4 months ago

Would supporting the import of plain-text chat backups be a better option? I grabbed copies of those too, and I've seen other apps (e.g. Telegram) use them for migrating messages around too.

The directory structure is a folder per chat, named after the recipient or group, with attachments and the chat log inside:

First Last/
    IMG-20240229-WA0000.jpg
    IMG-20240229-WA0001.jpg
    WhatsApp Chat with +44 7766 543210.txt
Group Name/
    WhatsApp Chat with Group Name.txt

The chat log itself looks like this:

29/02/2024, 12:33 - Your security code with +44 7766 543210 changed. Tap to learn more.
29/02/2024, 12:34 - My Name: Outgoing message
29/02/2024, 12:35 - +44 7766 543210: Incoming message
With multple lines
29/02/2024, 12:36 - ​My Name: IMG-20240229-WA0000.jpg (file attached)
29/02/2024, 12:37 - +44 7766 543210: <Media omitted>
29/02/2024, 12:38 - ​My Name: IMG-20240229-WA00001.jpg (file attached)
Caption for attachment
johanw666 commented 4 months ago

I think it would be easier to convert that to xml and use the existing plaintext import. But that won't work for groups, you would get the messages in a 1-1 conversation and not the group structure.

Terrance commented 4 months ago

It also wouldn't include media, which is more pressing as there's a lot of attachments that ideally I'd keep associated with their chats. Between this and a couple of chats from another app (one that provides its own backup format that I intend to massage into something suitable for Signal), it seems like the WA database is still the way to go, but groups without the message authors as members can't currently be imported in any of the flows.