-
Notifications
You must be signed in to change notification settings - Fork 245
feat: add group filter option #639
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
Open
sachitv
wants to merge
6
commits into
ReagentX:develop
Choose a base branch
from
sachitv:group_filter
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0f852b
feat: add group filter option
sachitv eaea13b
Merge branch 'develop' into group_filter
ReagentX 3396a49
Merge branch 'develop' into group_filter
ReagentX de1aec5
Merge branch 'develop' into group_filter
ReagentX 771c776
Merge branch 'develop' into group_filter
ReagentX 1cb864d
Merge branch 'develop' into group_filter
ReagentX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,13 @@ The [releases page](https://github.com/ReagentX/imessage-exporter/releases) prov | |
| All conversations with the specified participants are exported, including group conversations | ||
| Example: `-t [email protected],5558675309` | ||
|
|
||
| -g, --group-filter <group_name> | ||
| Filter exported group conversations by their names | ||
| To provide multiple group names, use a comma-separated string | ||
| Example: `-g "Family Chat,Work Group"` | ||
|
|
||
| Note: When both `--conversation-filter` and `--group-filter` are specified, only conversations that match both filters (intersection) will be exported. | ||
|
|
||
| -x, --cleartext-password <password> | ||
| Optional password for encrypted iOS backups | ||
| This is only used when the source is an encrypted iOS backup directory | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ pub const OPTION_PLATFORM: &str = "platform"; | |
| pub const OPTION_BYPASS_FREE_SPACE_CHECK: &str = "ignore-disk-warning"; | ||
| pub const OPTION_USE_CALLER_ID: &str = "use-caller-id"; | ||
| pub const OPTION_CONVERSATION_FILTER: &str = "conversation-filter"; | ||
| pub const OPTION_GROUP_FILTER: &str = "group-filter"; | ||
| pub const OPTION_CLEARTEXT_PASSWORD: &str = "cleartext-password"; | ||
| pub const OPTION_CUSTOM_CONTACTS_DB_PATH: &str = "contacts-path"; | ||
|
|
||
|
|
@@ -82,6 +83,8 @@ pub struct Options { | |
| pub ignore_disk_space: bool, | ||
| /// An optional filter for conversation participants | ||
| pub conversation_filter: Option<String>, | ||
| /// An optional filter for group chat display names | ||
| pub group_filter: Option<String>, | ||
| /// An optional password for encrypted backups | ||
| pub cleartext_password: Option<String>, | ||
| /// An optional path to a custom contacts database | ||
|
|
@@ -105,6 +108,7 @@ impl Options { | |
| let platform_type: Option<&String> = args.get_one(OPTION_PLATFORM); | ||
| let ignore_disk_space = args.get_flag(OPTION_BYPASS_FREE_SPACE_CHECK); | ||
| let conversation_filter: Option<&String> = args.get_one(OPTION_CONVERSATION_FILTER); | ||
| let group_filter: Option<&String> = args.get_one(OPTION_GROUP_FILTER); | ||
| let cleartext_password: Option<&String> = args.get_one(OPTION_CLEARTEXT_PASSWORD); | ||
| let contacts_path: Option<&String> = args.get_one(OPTION_CUSTOM_CONTACTS_DB_PATH); | ||
|
|
||
|
|
@@ -126,9 +130,10 @@ impl Options { | |
| (no_lazy, OPTION_DISABLE_LAZY_LOADING), | ||
| (start_date.is_some(), OPTION_START_DATE), | ||
| (end_date.is_some(), OPTION_END_DATE), | ||
| (custom_name.is_some(), OPTION_CUSTOM_NAME), | ||
| (use_caller_id, OPTION_USE_CALLER_ID), | ||
| (conversation_filter.is_some(), OPTION_CONVERSATION_FILTER), | ||
| (custom_name.is_some(), OPTION_CUSTOM_NAME), | ||
| (use_caller_id, OPTION_USE_CALLER_ID), | ||
| (conversation_filter.is_some(), OPTION_CONVERSATION_FILTER), | ||
| (group_filter.is_some(), OPTION_GROUP_FILTER), | ||
| ]; | ||
| for (set, opt) in format_deps { | ||
| if set { | ||
|
|
@@ -150,6 +155,7 @@ impl Options { | |
| (use_caller_id, OPTION_USE_CALLER_ID), | ||
| (custom_name.is_some(), OPTION_CUSTOM_NAME), | ||
| (conversation_filter.is_some(), OPTION_CONVERSATION_FILTER), | ||
| (group_filter.is_some(), OPTION_GROUP_FILTER), | ||
| ]; | ||
| for (set, opt) in diag_conflicts { | ||
| if diagnostic && set { | ||
|
|
@@ -265,6 +271,7 @@ impl Options { | |
| platform, | ||
| ignore_disk_space, | ||
| conversation_filter: conversation_filter.cloned(), | ||
| group_filter: group_filter.cloned(), | ||
| cleartext_password: cleartext_password.cloned(), | ||
| contacts_path: contacts_path.cloned().map(PathBuf::from), | ||
| }) | ||
|
|
@@ -447,20 +454,28 @@ fn get_command() -> Command { | |
| .display_order(13) | ||
| .value_name("filter"), | ||
| ) | ||
| .arg( | ||
| Arg::new(OPTION_GROUP_FILTER) | ||
| .short('g') | ||
| .long(OPTION_GROUP_FILTER) | ||
| .help("Filter exported group conversations by their names\nTo provide multiple group names, use a comma-separated string\nExample: `-g \"Family Chat,Work Group\"`\n") | ||
| .display_order(14) | ||
| .value_name("group_name"), | ||
| ) | ||
| .arg( | ||
| Arg::new(OPTION_CLEARTEXT_PASSWORD) | ||
| .short('x') | ||
| .long(OPTION_CLEARTEXT_PASSWORD) | ||
| .help("Optional password for encrypted iOS backups\nThis is only used when the source is an encrypted iOS backup directory\n") | ||
| .display_order(14) | ||
| .display_order(15) | ||
| .value_name("password"), | ||
| ) | ||
| .arg( | ||
| Arg::new(OPTION_CUSTOM_CONTACTS_DB_PATH) | ||
| .short('n') | ||
| .long(OPTION_CUSTOM_CONTACTS_DB_PATH) | ||
| .help("Optional custom path for a macOS or iOS contacts database file\nThis should be resolved automatically, but can be manually provided\nHandles from the messages table will be mapped to names in the provided database\nGenerally, one of `AddressBook-v22.abcddb` or `AddressBook.sqlitedb`\n") | ||
| .display_order(15) | ||
| .display_order(16) | ||
| .value_name("path"), | ||
| ) | ||
| } | ||
|
|
@@ -486,6 +501,7 @@ impl Options { | |
| platform: Platform::macOS, | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| } | ||
|
|
@@ -535,6 +551,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -618,6 +635,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -652,6 +670,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -732,6 +751,7 @@ mod arg_tests { | |
| platform: Platform::iOS, | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -771,6 +791,7 @@ mod arg_tests { | |
| platform: Platform::iOS, | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: Some("password".to_string()), | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -826,6 +847,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -857,6 +879,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -889,13 +912,23 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: Some(String::from("[email protected]")), | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
||
| assert_eq!(actual, expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn can_build_option_group_filter() { | ||
| let command = get_command(); | ||
| let args = command.get_matches_from(["imessage-exporter", "-g", "Family Chat", "-f", "txt"]); | ||
|
|
||
| let actual = Options::from_args(&args).unwrap(); | ||
| assert_eq!(actual.group_filter, Some(String::from("Family Chat"))); | ||
| } | ||
|
|
||
| #[test] | ||
| fn can_build_option_full() { | ||
| // Get matches from sample args | ||
|
|
@@ -920,6 +953,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -951,6 +985,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: false, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
@@ -1024,6 +1059,7 @@ mod arg_tests { | |
| platform: Platform::default(), | ||
| ignore_disk_space: true, | ||
| conversation_filter: None, | ||
| group_filter: None, | ||
| cleartext_password: None, | ||
| contacts_path: None, | ||
| }; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only validates the
group_filterfield. Consider testing the completeOptionsstruct (like other tests in this module) to ensure all fields are set correctly when using the group filter option.