bepaald / signalbackup-tools

Tool to work with Signal Backup files.
GNU General Public License v3.0
755 stars 36 forks source link

Need mergeRecipients function #181

Closed possum-enjoyer closed 7 months ago

possum-enjoyer commented 7 months ago

Hello, the mergeRecipients function is declared deprecated and i should open an issue if i need this. So i do and i really need this feature

bepaald commented 7 months ago

Hi!

So the reason it was deprecated was mostly because I never updated it for the complications of V2 groups (plus the fact nobody used this function I think). But most of the other functionality was already there.

I just had a go at updating this function. Now, for normal messages (quotes/mentions/etc...) everything should work (for both 1-on-1 and group messages). Also, the 1-on-1 threads should be properly merged.

What doesn't work: group-change messages (like "Bob changed the group name to 'Something'" or "Alice added Bob to the group", and many more). These messages do not reference the recipient by the _id like in other places, but by uuid. As long as the old and new recipients exist in your address list under the same name, there should be visually no difference.

Also, the --editgroupmembers option was removed: this was always a bad idea, group memberships can not be changed by editing the backup file. The new number should simply be added to the group (if still active) and the old removed (optionally) in the normal way.

Usage: signalbackup-tools [input] [passphrase] --mergerecipients "OLDNUMBER","NEWNUMBER" -o [output], where OLDNUMBER and NEWNUMBER are the phone numbers exactly as the appear in the database (use --listrecipients to list them if unsure, the phone number-column may be named e164).

Remember to keep a copy of your original backup in case something goes wrong. You could add --exporthtml to inspect the results before restoring to phone. This gives no guarantees on success, but might show obvious problems. If everything looks ok, restore to phone and check the results as thoroughly as possible, scroll around in different conversations and see if anything is wrong or if the application crashes.

Please let me know the results! Thanks!

possum-enjoyer commented 7 months ago

Hey,

I used --mergerecipients yesterday and it worked flawlessly with the current database version 215. Two chats merged by two different numbers for the same person + two backups were merged without only some errors with stickers but those can be ignored tbh. Thanks so much for all the features you provide with this tool.

I did check with an html export and found some duplicates at the intersection of both backups. Wil some datetime cropping i think i can restore my backup completly.

bepaald commented 7 months ago

Hi, thanks for getting back with the results. Glad it seemed to have worked!

I'm curious about the sticker errors you noticed. I agree they are probably not very important (as long as they don't cause a crash or anything like that, stickers can always be reinstalled). But do you have any details about the errors? Were these errors printed by this tool during the merge or things you saw in the (html) output that were incorrect?

When merging backups that contain the same messages, duplicates can indeed occur and one of the backups should be cropped beforehand.

Thanks for your kind words!

possum-enjoyer commented 7 months ago

hey sorry for the late reply.

Yeah those sticker errors where printed by the tool. It's only one error though:

[Warning]: Sticker data not found (rowid: XXXX) Dealing with table 'sticker'... YYYY/XXXX entries...

Yeah i cropped the latter of the two backups and now have one working backup again!

bepaald commented 7 months ago

No worries, thanks for the feedback!

That warning is pretty normal for attachments, I actually have a function to suppress that warning when the circumstances are such that the attachment is expected to be missing. I should probably call that function for Stickers as well (internally Stickers are basically the same as any other attachment).

Glad you got everything working!