Skip to content
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

[Feat] Import contact names from exported google vcards and more #106

Merged
merged 20 commits into from
Jul 20, 2024

Conversation

Bnaya
Copy link
Contributor

@Bnaya Bnaya commented Jul 8, 2024

Hey
first thank you very much for this utility!

I've made some modifications for my own use cases, that i think could be useful for more users.
I would like to receive preliminarily feedback before i finalize things, and write some docs about it.
I am not a python developer, so it's very possible i did thinks in a very not "python way"

Main features:
"--enrich-names-from-vcards"
I had the empty contact issue, and not over come it, i wrote an option to load exported vcards file exported from google contact.
I had to also add --default-country-code-for-enrich-names-from-vcards
But maybe there is a robust way to infer it?

More features:
--filter-empty
Will filter chats that are only system messages like the "chat is end to end encrypted"
In my case that but the number of chats from 16K to 2.6K

--avoidJSONEnsureAscii see code
--prettyPrintJson

I tried to be very carful to not make any breaking change

@Bnaya Bnaya changed the title Bnaya's assorted features Import contact names from exported google vcards and more Jul 8, 2024
@Bnaya Bnaya changed the title Import contact names from exported google vcards and more [Feat] Import contact names from exported google vcards and more Jul 8, 2024
@KnugiHK KnugiHK self-requested a review July 9, 2024 12:30
@KnugiHK
Copy link
Owner

KnugiHK commented Jul 9, 2024

Hi! Thanks for your contribution. I will make changes to the PR so that the commits look more Pythonic.

@Bnaya Bnaya marked this pull request as ready for review July 9, 2024 18:41
@Bnaya
Copy link
Contributor Author

Bnaya commented Jul 9, 2024

Sure, feel free to edit/remove stuff

Copy link
Owner

@KnugiHK KnugiHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some changes. Please confirm if the features added are still working as expected.

@Bnaya
Copy link
Contributor Author

Bnaya commented Jul 15, 2024

I've pushed 13904ea
And now it's working properly

I don't have merge permission

@KnugiHK KnugiHK changed the base branch from main to dev July 20, 2024 05:42
@KnugiHK KnugiHK added the enhancement New feature or request label Jul 20, 2024
@KnugiHK
Copy link
Owner

KnugiHK commented Jul 20, 2024

LGTM.

@code-consensus
Copy link

Hi,

There is a simpler way to implement the filtering of empty chats (this commit), that only involves two lines of SQL code and no other changes to the code base.

That is, no new functions would be required (e.g. is_chat_empty() not needed, _is_message_empty() etc), and no changes to the various functions (e.g. create_html() stays the same) and no need to change the way the json exporting works.

It operates on the basis that chat.sort_timestamp is NULL if there is no chat content in a chat -- the exception seems to be broadcasts (which is easily dealt with).

Specifically then, using the v0.10.0 code base, inside the messages() function at line 255 in android_handler.py, you have the SQL query:

  1. Under SELECT, add the following line: chat.sort_timestamp, e.g. after chat.subject as chat_subject, on line 271

  2. At line 314, replace WHERE key_remote_jid <> '-1' with:
    WHERE key_remote_jid <> '-1' AND (chat.sort_timestamp IS NOT NULL OR key_remote_jid LIKE '%broadcast%')

I have tested this on my databases, and it filters out all the @lid chats, all phone numbers that have no chat content, etc.
I don't have access to iOS and not knowledgeable on how the iOS msgstore.db is set up, but I imagine a similar SQL code could be implemented in iOS to achieve the same result.

@KnugiHK
Copy link
Owner

KnugiHK commented Nov 2, 2024

Hi,

There is a simpler way to implement the filtering of empty chats (this commit), that only involves two lines of SQL code and no other changes to the code base.

That is, no new functions would be required (e.g. is_chat_empty() not needed, _is_message_empty() etc), and no changes to the various functions (e.g. create_html() stays the same) and no need to change the way the json exporting works.

It operates on the basis that chat.sort_timestamp is NULL if there is no chat content in a chat -- the exception seems to be broadcasts (which is easily dealt with).

Specifically then, using the v0.10.0 code base, inside the messages() function at line 255 in android_handler.py, you have the SQL query:

1. Under SELECT, add the following line: `chat.sort_timestamp,` e.g. after `chat.subject as chat_subject,` on [line 271](https://github.com/KnugiHK/WhatsApp-Chat-Exporter/blob/77c5a3e20c626c8d2cba12978e947b9c38815433/Whatsapp_Chat_Exporter/android_handler.py#L271)

2. At [line 314](https://github.com/KnugiHK/WhatsApp-Chat-Exporter/blob/77c5a3e20c626c8d2cba12978e947b9c38815433/Whatsapp_Chat_Exporter/android_handler.py#L314), replace `WHERE key_remote_jid <> '-1'` with:
   `WHERE key_remote_jid <> '-1' AND (chat.sort_timestamp IS NOT NULL OR key_remote_jid LIKE '%broadcast%')`

I have tested this on my databases, and it filters out all the @lid chats, all phone numbers that have no chat content, etc. I don't have access to iOS and not knowledgeable on how the iOS msgstore.db is set up, but I imagine a similar SQL code could be implemented in iOS to achieve the same result.

Hi! As we discussed in another issue, I've noticed that the sort_timestamp may not filter chats accurately. I’ll take a closer look at your concern when available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants