bepaald / signalbackup-tools

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

Question: crtoptodate vs. limittodates #224

Closed DummerJunge closed 1 month ago

DummerJunge commented 1 month ago

Hello and thanks for this nice programm.

Using .\signalbackup-tools_win.exe "signal.backup" "..." --setselfid "+..." --exporthtml emptydir --limittodates ",2024-01-01 00:00:00" --allhtmlpages I expected only conversations up to beginn of 2024, but all where exported.

Nevertheless .\signalbackup-tools_win.exe "signal.backup" "..." --setselfid "+..." --exporthtml emptydir --croptodates ",2024-01-01 00:00:00" --allhtmlpages works as expected.

Interestingly this wrong command line .\signalbackup-tools_win.exe "signal.backup" "..." --croptodates ",2024-01-01 00:00:00" --setselfid "+..." --exporthtml emptydir --limittodates --allhtmlpages gave no warning, limits the conversations but does not write the additional HTML files.

bepaald commented 1 month ago

Hi! Thanks for the feedback, it has given me a few ideas about things to improve. I've made a few adjustments already, but am not finished with them yet. I'll continue on them a little later.

Using .\signalbackup-tools_win.exe "signal.backup" "..." --setselfid "+..." --exporthtml emptydir --limittodates ",2024-01-01 00:00:00" --allhtmlpages I expected only conversations up to beginn of 2024, but all where exported.

As far as I can tell, this works for the actual conversations, but the index.html page does is not limited properly. Could you confirm this is the case? (now that I think about it, the call-log is probably also not limited)

I have already made a small adjustment so that conversations that do not exist within the listed dates are no longer shown on the index page. However, the 'snippet' and date on the index page are still not right. I will work on them later.

Nevertheless .\signalbackup-tools_win.exe "signal.backup" "..." --setselfid "+..." --exporthtml emptydir --croptodates ",2024-01-01 00:00:00" --allhtmlpages works as expected.

--croptodates will actually modify the backup file. If you'd add --output [output] to that command you get an altered backup, while if you added that to the previous command, the output would be a copy of the original: --limittothreads only modifies the behavior of --exporthtml, but does not alter the backup file at all. The cropping function is a bit more complex and writes new 'snippets' and dates to the threads-list, which are then also exported to the html file.

Interestingly this wrong command line .\signalbackup-tools_win.exe "signal.backup" "..." --croptodates ",2024-01-01 00:00:00" --setselfid "+..." --exporthtml emptydir --limittodates --allhtmlpages gave no warning, limits the conversations but does not write the additional HTML files.

This was all due to the actual argument to --limit/croptodates not being validated during argument parsing. This resulted in no immediate error being shown and the --allhtmlpages option being swallowed (it was considered the required argument to limittodates). I have now added some code to attempt to validate the dateranges early, so this is hopefully fixed now.

Note the parser now also disallows empty dates, so ",2024-01-01 00:00:00" needs to be written as "0,2024-01-01 00:00:00".

I hope that answers some questions. I will work on writing correct snippets and dates on the index page and limiting the call log in the coming days.

DummerJunge commented 1 month ago

Thank you.

As far as I can tell, this works for the actual conversations, but the index.html page does is not limited properly. Could you confirm this is the case? (now that I think about it, the call-log is probably also not limited)

Correct, conversations are limited to the end date but index page and call log not.

bepaald commented 1 month ago

Thanks for letting me know.

I have made some more changes, and now I hope the index.html and calllog.html are also correct when using --limittodates. Fixing the index was much more complicated than I thought it would be. Some things are hard (or impossible) to do correctly in this situation, but it should at least be as good as it is with --croptodates. Please let me know if you try this and see anything that's obviously wrong.

Thanks again!

DummerJunge commented 1 month ago

.\signalbackup-tools_win.exe "signal.backup" "..." --setselfid "+..." --exporthtml emptydir --limittodates "0,2024-01-01 00:00:00" --allhtmlpages works like -croptodates, great job, thanks.