himalaya/tests/imap_test.rs

150 lines
4.1 KiB
Rust
Raw Normal View History

refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
use std::convert::TryFrom;
2021-05-02 21:49:20 +00:00
2021-05-04 21:19:05 +00:00
use himalaya::{
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
config::model::Account, flag::model::Flags, imap::model::ImapConnector, mbox::model::Mboxes,
msg::model::Msgs, smtp,
2021-05-04 21:19:05 +00:00
};
2021-05-02 21:49:20 +00:00
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
use imap::types::Flag;
use lettre::message::SinglePart;
use lettre::Message;
2021-05-02 21:49:20 +00:00
fn get_account(addr: &str) -> Account {
Account {
name: None,
downloads_dir: None,
2021-08-04 20:25:45 +00:00
signature_delimiter: None,
2021-05-02 21:49:20 +00:00
signature: None,
default_page_size: None,
default: Some(true),
email: addr.into(),
2021-05-08 11:49:13 +00:00
watch_cmds: None,
2021-05-02 21:49:20 +00:00
imap_host: String::from("localhost"),
imap_port: 3993,
imap_starttls: Some(false),
imap_insecure: Some(true),
imap_login: addr.into(),
imap_passwd_cmd: String::from("echo 'password'"),
smtp_host: String::from("localhost"),
smtp_port: 3465,
smtp_starttls: Some(false),
smtp_insecure: Some(true),
smtp_login: addr.into(),
smtp_passwd_cmd: String::from("echo 'password'"),
}
}
#[test]
fn mbox() {
let account = get_account("inbox@localhost");
let mut imap_conn = ImapConnector::new(&account).unwrap();
2021-05-04 21:19:05 +00:00
let names = imap_conn.list_mboxes().unwrap();
let mboxes: Vec<String> = Mboxes::from(&names)
2021-05-02 21:49:20 +00:00
.0
.into_iter()
.map(|mbox| mbox.name)
.collect();
assert_eq!(mboxes, vec![String::from("INBOX")]);
imap_conn.logout();
}
#[test]
fn msg() {
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
// Preparations
2021-05-02 21:49:20 +00:00
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
// Get the test-account and clean up the server.
let account = get_account("inbox@localhost");
2021-05-02 21:49:20 +00:00
2021-05-03 16:42:09 +00:00
// Login
2021-05-02 21:49:20 +00:00
let mut imap_conn = ImapConnector::new(&account).unwrap();
2021-05-03 16:42:09 +00:00
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
// remove all previous mails first
let fetches = imap_conn.list_msgs("INBOX", &10, &0).unwrap();
let msgs = if let Some(ref fetches) = fetches {
Msgs::try_from(fetches).unwrap()
} else {
Msgs::new()
};
// mark all mails as deleted
for msg in msgs.0.iter() {
imap_conn
.add_flags(
"INBOX",
&msg.get_uid().unwrap().to_string(),
Flags::from(vec![Flag::Deleted]),
)
.unwrap();
}
imap_conn.expunge("INBOX").unwrap();
// make sure, that they are *really* deleted
assert!(imap_conn.list_msgs("INBOX", &10, &0).unwrap().is_none());
// == Testing ==
// Add messages
let message_a = Message::builder()
.from("sender-a@localhost".parse().unwrap())
.to("inbox@localhost".parse().unwrap())
.subject("Subject A")
.singlepart(SinglePart::builder().body("Body A".as_bytes().to_vec()))
.unwrap();
let message_b = Message::builder()
.from("Sender B <sender-b@localhost>".parse().unwrap())
.to("inbox@localhost".parse().unwrap())
.subject("Subject B")
.singlepart(SinglePart::builder().body("Body B".as_bytes().to_vec()))
.unwrap();
smtp::send(&account, &message_a).unwrap();
smtp::send(&account, &message_b).unwrap();
// -- Get the messages --
2021-05-03 16:42:09 +00:00
// TODO: check non-existance of \Seen flag
2021-08-18 20:13:07 +00:00
let msgs = imap_conn.list_msgs("INBOX", &10, &0).unwrap();
2021-05-08 11:49:13 +00:00
let msgs = if let Some(ref fetches) = msgs {
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
Msgs::try_from(fetches).unwrap()
2021-05-08 11:49:13 +00:00
} else {
Msgs::new()
};
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
// make sure that there are both mails which we sended
2021-05-03 16:42:09 +00:00
assert_eq!(msgs.0.len(), 2);
let msg_a = msgs
.0
.iter()
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
.find(|msg| msg.headers.subject.clone().unwrap() == "Subject A")
2021-05-03 16:42:09 +00:00
.unwrap();
let msg_b = msgs
.0
.iter()
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
.find(|msg| msg.headers.subject.clone().unwrap() == "Subject B")
2021-05-03 16:42:09 +00:00
.unwrap();
refactor msg model (#173) * Adding Mail structure Adding a main structure which can be used for *everything* which has to do with a mail: - Writing a new mail - Fetching the information of a mail * Write mails User can write mails now * Writing mail When mail is converted to a sendable message, it'll print out a nice little error message what to do and which field is missing a value. * Mail List subcommand works with new struct now. * Forwarding Started implementation for forwarding message * Breaking Commit This is just a "backup" commit * First finished Himalaya can compile successfully now. * Removed uneccessary files - Moved everything from msg/mail to msg/model - Removed uneccessary files * Renaming Renamed all "Mail" and "Mails" struct to "Msg" and "Msgs". * Cleaning Removed an CLI-Subcommand which can't be used anymore * Flags Fixed flags to vector and added the template subcommand back * Changes to Flags Changed the datatype from Vec<Flag<'static>> to HashSet<Flag<'static>>, because each Message/Mail can include only one flag-type, so why not a HashSet for this job? * Cargo.toml changes Fixed the lettre-dependencie which points to the pull request with the given serde implementation for ContentType (needed for Attachments). * Fix Template bug and removed unnecessary files. - Removed the msg/flag/flag.rs file since we can use the imap::types::Flag implementation now - `himalaya template new` printed the template two times. This should be fixed now * Template command Fixed formatting when printing out template * Sending Mail Fixed bug that user can't send a mail * Msg Moved the body from the attachment-vector out to an external attribute of the struct. * Msg listing and changed Msg::from to Msg::try_from - Fixed bug that listing didn't showed up addresses in the `From:` field for example - Made each `from` trait function to `try_from` for better error-handling * Tests - Fixed tests in `tests/imap_conn.rs` * Cargo.toml changes, Bug fixes, Documentation - Updated mailparse to 0.13.4 - Added new "new" function to Account - Cleaned up some functions (removed some) - Added Eq and PartialEq derives for msg - Bugfix: It couldn't get the body of some mails, because they were inside a multipart/alternative part. Now the mail is iterating through all subparts and picks up the firs text/plain "attachment" and uses it as the body. * Changed Msg attributes viewability - Made the "main attributes" of the Msg struct public - Removed to getter functions * Big envelope changes - Added documentation - Removed the getter functions, beacuse the attributes are public * Documentation and Cleanup - Removed the `new` constructor of the envelope, since it's actually the same as Envelope::default() - Addded tests and Documentation to Attachments.rs * Documentation and Tests - Added docuemntation for msg/body.rs - Fixed some syntax errors in the doc strings * General msg - Added `get_raw` function and `raw` field for the `Msg` struct. - Fixed raw output of msg - Started documentation + tests for the Msg struct * Changes to Msg - Added Clone derive - Added documentation for change_to_reply method - Added tests to change_to_reply method * Msg tests and Account changes - Changed `Account::new()` function - Added more documentation to Msg struct - Added more tests to Msg struct * Removed an unknown file Removed src/.rust_info.json (don't know where it came) * Msgs finished(?) Added final documentation to the Msg struct. * ImapConnector Fix Fixed the bug, when trying to move a msg, the envelope wasn't applied to the fetch. Fixed that in the `get_msg` method. * Msg - Bug fixes: - Adding Message ID and Subject in the to_sendable_msg function - Removed an println statement for debugging - Added more error messages * Cargo.toml Changed order and added some comments to the dependencies. * Msg Removed an unnecessary documentation part. * Fixed documentation * Removing non-debugflags for dev profile Removing debug=false for the dev profile since it was just for me. * Cleanup Removed the comment blocks and reduced some comments * Cleanup Reformatted some stuff * Cleanup Replaced the word "mail" with "msg". * Formatting Fixed formatting in src/flag/model.rs file * Little fix * Changes and tests - New "feature": If you reply to a reply, the subject won't look like this for example: Re: Re: Re: Re: Re: Re: The subject - Fixed tests. All tests pass now (run `cargo test`) * Idea(?) Renamed all <module>_matches/_subcmds to general "matches" and "subcmds()". All modules have the same: "matches()" and "subcmds()" * Little fix Changed the name from "imap_conn" to "conn" by mistake. Fixed that * Bug fix When sending a message, himalaya will generate a UUID on its own if there's no message-id for the message yet. * Bug fix Removed angle brackets, since they are added through the lettre library. * Bugfix Removed an unnecessary (old) line. * Cleanup Removed the last comment blocks. * Fixed lettre dependencie * Bugfixes and Error handling - When calling the msg_interaction function, the user can edit the msg first, before the prompt comes up - Also added a error output, if the msg couldn't be converted into a sendable message. * Error handling Improved output of error * Bug fixes, Error Handling - Improved error handling for the string parsing - Added attempt to fix the bug that a whitespace is added in the end of an address * Trimming Added trims to avoid invalid white spaces in the addresses. * Fixing whitespace bug All addresses are gonna trimmed before adding to a header now * Adding encoding, Changed dependencie - Added encoding for the body part - Changed the lettre dependencie of lettre to TornaxO7's fork of lettre, because the "ContentTypeEncoding" struct needs the "Eq", "Serialize" and "Deserialize" derives. * Improved Error handling Added a warning, if a message included an unknown attachment. * Fixed tests Fixed the documentation for passing the tests. * Doc change * Bugfis: When replying, signature is added now as well * Bugfix: Forwarding Message When forwarding a message, himalaya, put the signature in the end of the mail/msg. Now it's added above the '-------Forwarded Message---------' line. * Readjusted tests and new method - Changed the way to create a new account: - Account::new => Sets signautre to "None" - Account::new_with_signature => Sets signature to the given argument This makes it more flexible to create specifique accounts for tests for example. - Fixed the tests so all are passing now * improve sig and sig delim concat process * add signature delim struct comment * fix signatures + tests * fix body and signature new lines * Adding [serde(rename_all = "camelCase")] to structs * fix reply indentation and signature new lines * add default rustfmt.toml * apply fmt on all the project * fix msg tests * Makeing Ctx struct independent - The Ctx struct doesn't include references anymore. This makes it easier to create new Ctx instances by doing the following: Ctx { <attribute>: <value>, .. Ctx::default() } This helps especially for writing tests. Also the attributes of the Ctx struct in the main-entry function aren't used anymore after creating the Ctx struct. So there's no need to have only references in the Ctx struct. * Fixing JSON output - JSON of message includes `hasAttachment` key now - JSON output shows both body types: Text and Html - Changed `Body` struct so it can store html and text now. * Tests Updated tests with the latest Body implementation * Fixes - Removed suspicious println macro in serializer of msg... *cough cough* - Fixed output in the "read" command - othe small fixes * Formatting Formatted all files * Msg - Adding 'get_full_message' method which prints out all information of the message in a string * New Msg-Struct Adding MsgSerialized, a struct, which represents the "correct" serialized version of a message because it includes another attribute: `has_attachment`. * Cleanup Removed the manual serialize implementation of `Msg` and added a little more info about the MsgSerialized. * Test fixes Adjusted all tests so all are passing now. * Little changes - Used a better condition for checking if the message includes attachments or not - format fixes * Fixing tests and Docs - Provided more docs - Refactored tests and added more tests * Expanding specials Added more "special characters" which will add some quotes around the name if it includes at least one of them. * Fixing test Improved the detection if the mail-name includes a special character or not. * Variable renaming Renamed a variable for better readability. * Envelope renaming * Small change Renamed the variable of the `TryFrom` implementation for the imap_proto::Envelope. * Last stuff - Making the attributes of mboxes independent. We can store them now as well! - Added more docs - Added type-safety for flags - Expanded flags a bit - Added more tests - Added a short summary of the file-structure in the beginning of the doc. * Help command fix Fixing help command description. * Small doc change * Doc fix Fixing the link to the mbox delimiter. * Fixing typo * Doc fix * Added docs for Output struct * Fixing tests Fixing a little test issue * Formatting changes + doc change - Removed bold + capital words for logout-doc - Run format on each *.rs file * Fixing tests - Testing the return value of the flags struct as a string doesn't really work since it's a HashSet => Converted it into a Vec (in the test) to set the order as well. - Fixed imap test by reverting the changes in the test. * Error handling Changed error output when creating an Imap-Connection. Should help debugging :) * Formatting fixes and refactoring - Using `trim_end_matches` instead of "pop"s now. - Executed `cargo fmt` * Trying to fix test workflow * Fixes Updated dependencies with `cargo update` and let cargo point to master branch of TornaxO7's lettre-fork because this should probably fix the issue with the nix-build. * Test fix Fixing the workflow. * Workflow fix Removing semicolon * Starting workflow Added a new line to be able to push. * Workflow Reverting the workflow command. * Workflows Reverting workflow to master workflow. * let actions/checkout@v2 run first * Forwarded message's signature misplaced Changes the order of the signature for forwarded messages. * Output change Changed the output if an error occurs. * Fixing output for template-building * Template shows raw data with JSON format #23 When printing the message in json, the raw message is printed out as a string now. * the_sender_is_not_displayed_properly_in_table_and_json #21 - When displaying the table, we'll look first, if a name exists, if yes => use it otherwise use the email address. - Added the rfc2047_decoder for parsing addresses * Formatting Run 'cargo fmt' Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com> Co-authored-by: Erik <erik1000@protonmail.com>
2021-09-10 22:35:22 +00:00
// -- Checkup --
// look, if we received the correct credentials of the msgs.
assert_eq!(
msg_a.headers.subject.clone().unwrap_or_default(),
"Subject A"
);
assert_eq!(&msg_a.headers.from[0], "sender-a@localhost");
assert_eq!(
msg_b.headers.subject.clone().unwrap_or_default(),
"Subject B"
);
assert_eq!(&msg_b.headers.from[0], "Sender B <sender-b@localhost>");
2021-05-03 16:42:09 +00:00
// TODO: search messages
// TODO: read message (+ \Seen flag)
// TODO: list message attachments
// TODO: add/set/remove flags
// Logout
2021-05-02 21:49:20 +00:00
imap_conn.logout();
}