-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add save_attachments action and provide enhancements to search_items action. #17
Add save_attachments action and provide enhancements to search_items action. #17
Conversation
…ry to store attachments.
… conflict with other initialization processes.
…output when item type is (email) "Message".
…b "Mailbox" class.
…a dateutil library for parsing.
…timezone configuration parameter for conversion to EWSDateTime.
…a dateutil library for parsing.
…m-msexchange into save_attachments
…lass attributes to int().
…ters congruent with config parameter names.
…directly by combination of item ID and change key.
…essage, calendar item, etc.) by combination of item ID and change key directly.
…tion of MS Exchange message ID (email only) and change key to uniquely identify message for which to save attachments.
…r parameter in _get_item_by_id() method.
…cause results may not have this attribute in case message obtained by combination of message ID and change key.
…ion change on 3.0 and later that returns "zoneinfo" objects instead of "pytz" object, which breaks exchangelib version.
@tonybaloney Hi. Just checking on status of this pull request. I don't anticipate any further changes on my branch in the near future and would like to get it merged into "master" when possible. Thanks! |
Please remove |
Sorry for the delay in making this update. Should be good now. |
Common method for searching for MS Exchange items (email messages, | ||
calendar items, etc.). Used by _search_items_ and _save_attachments_. | ||
""" | ||
folder = self.account.root.get_folder_by_name(folder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might also be a nice feature to add is_read filter to the items search. This would allow someone the option of ignoring items that are already marked as read. |
I'm happy with this change, @minsis are your comments improvements, or do they need to be addressed for your use-cases before this is merged? |
They're just improvements and not requirements at this time. However, to upgrade exhangelib it will be required to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - changes look good to me, and thanks for the contribution and the enhancements.
It would be good to get some tests into this pack, but I'm not going to hold up this PR for that as we don't have any tests. So putting in a basic test structure for this pack probably should go in as a PR in its own right.
1.1.0
Add
save_attachments
action.attachment_directory
: Fully-qualified server path name used to store attachments. Must be readable and writeable by Stackstorm. Defaults to "/opt/stackstorm/packs/msexchange/attachments".attachment_folder_maximum_size
: Maximum storage space in MB (default is 50MB) alloted toattachment_directory
. Pack maintenance process (see below) manages this.attachment_days_to_keep
: Maximum number of days to keep saved attachments (default is 7 days). Also, managed by pack maintenance process.search_items
for finding email messages for which to save attachments. Only email messages and file attachments are supported.email_subject
- Full subject of the email.email_sent
- Date that email was sent.sender_email_address
- Email address of the sender.attachment_files
- List/array of fully-qualified filenames from server of attachments saved. Example:attachment_directory_maintenance
sensor/trigger/rule combination has been implemented and, by default, runs once daily (polling interval of 86400 seconds) to enforce these rules through thedo_attachment_directory_maintenance
action. This action can be run manually, as well, if you need to override the pack configuration values; running manually it with no input values uses the pack configuration.Enhancements to
search_items
action.run
method insearch_items
action into_search_items
utility method inbase/actions.py
to allow functionality to be shared bysearch_items
andsave_attachments
.search_start_date
parameter specifying the start date for items to search. (End date is always "today".) Date can be entered as free-form text. Most any date format is supported, asdateutil
library is used to parse input to validdatetime
value.search_items
action to return additional item attributes, specific to email messages, fromitem_to_dict
helper method. Such attributes can be useful in filtering e-mails based on sender and/or originating domain.sender_email_address
- Email address of sender.email_recipient_addresses
- List/array of email recipients (fromexchangelib
to_recipients
list only).folder_name
parameter toitem_to_dict
helper method to include the name of the folder used in the search as attribute of returned dictionary.requirements.txt
to includepython-dateutil
(see above) andpytz
, which is needed for creating timezone-awareexchangelib
EWSDateTime
objects for date searches.