Commit graph

118 commits

Author SHA1 Message Date
mtraeber
e0712171a6 fix: frappe-linter, all queries in email_account.py and receive.py rewritten
according to these specifications: https://frappeframework.com/docs/user/en/api/query-builder
2021-11-23 15:54:00 +01:00
mtraeber
151768d1d9 added method param again after merge 2021-11-03 09:36:00 +01:00
mtraeber
8a7889b928 Merge branch 'develop' into multiple_imap_folder 2021-11-03 08:55:29 +01:00
Ankush Menat
af4ce8156d
fix: remove mutable defaults (#14597)
* fix: mutable defaults

* fix: missing defaults
2021-10-28 09:36:31 +00:00
mtraeber
f608fbeddd feat: sync mutliple IMAP folders in Email Account
When working with IMAP accounts, frappe should allow the user
to choose multiple folders to look for new mails. This helps
users to separate their frappe-related email from other
conversations. Use cases range from sieve filters in the
mail server that stuff incoming mail in various mail folders
to people manually sorting their e-mail. In both cases, we
can have different import policies for different folders, and
we can avoid importing unrelated email.

Created a new child table `IMAP Folder` with following fields:
 - Folder Name (user-modifiable)
 - Append To (user-modifiable)
 - UIDVALIDITY (hidden)
 - UIDNEXT (hidden)

Doctype `Email Account` and `receive.py` code adjusted so that
emails with the changes are processed correctly and Frappe
only logs in to the imap server once per sync.

Created a patch that copies the data from the old fields into
the new child table with `INBOX` as default `folder_name`. This
keeps existing setups working without manual changes.

The original fields
 - uidvalidity
 - uidnext
 - append_to
are still available for the pop3 setups. In IMAP, these fields
are hidden user and not used.

Added a test case in `Email Account` that validates data to make
sure a IMAP folder is provided if the use_imap is true.

Also added some code formatting changes in email_account.js to get rid
of sider checks failures that block this change
2021-10-13 10:27:18 +02:00
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
leela
f54600a400 fix: incoming mail handler
While creating a communication record from incoming mail is failing
in a case where there exists a reference document.

reason for bug is misspelled `self.from_email` as `email.from_email`
2021-06-17 07:31:10 +05:30
leela
70a1cfb1ab fix: inbound mail handling for pop3 protocol 2021-06-04 06:55:17 +05:30
Gavin D'souza
8558116c70 Merge branch 'develop' of github.com:frappe/frappe into drop-py2-code 2021-05-31 18:28:28 +05:30
leela
4ce8a600e8 fix: Tests and sider issues 2021-05-31 10:02:13 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
leela
5b96b79ed4 refactor: incoming mails 2021-05-21 18:57:18 +05:30
Gavin D'souza
b3af9f0c72 fix: Use raw strings for strings with \
Avoid DeprecationWarning which will turn into SyntaxError in later
Python versions
2021-05-07 17:59:20 +05:30
Rohan Bansal
86851028ea feat: manage Python 3 compatiblity with dependencies 2021-04-14 14:40:58 +05:30
Suraj Shetty
aef8ecc7ef fix: Show custom message for invalid login credentials 2020-11-03 12:43:39 +05:30
Saurabh
2ad5f1ea24 fix: handle FileAlreadyAttachedException while pulling email 2020-10-14 19:15:39 +05:30
Chinmay D. Pai
4d48a2a032
fix(email): handle case where cstr returns text_type of str
chardet requires input to be bytes or bytesarray, but sometimes
frappe.cstr() returns text_type of str without encoding it to utf-8

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-12-27 16:28:09 +05:30
Chinmay Pai
d169f41a54 fix(email): try to encode email part to utf-8 (#8965)
fixes issues with class objects other than str

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 281, in receive
    communication = self.insert_communication(msg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 338, in insert_communication
    email = Email(raw)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 372, in __init__
    self.parse()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 393, in parse
    self.process_part(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 445, in process_part
    self.text_content += self.get_payload(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 489, in get_payload
    charset = self.get_charset(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 484, in get_charset
    charset = chardet.detect(frappe.safe_encode(part))['encoding']
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/chardet/__init__.py", line 34, in detect
    '{0}'.format(type(byte_str)))
TypeError: Expected object of type bytes or bytearray, got: <class 'email.message.Message'>

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-12-09 19:25:43 +05:30
Faris Ansari
488c68df96
Merge branch 'develop' into refactor-scheduler 2019-12-02 13:16:45 +05:30
Rushabh Mehta
7cd329fac9 reactor(scheduler): created "Scheduler Job Type" and cleaned up scheduler 2019-11-07 12:14:09 +05:30
Rucha Mahabal
ac41e46ed6 fix(Email): poplib.error_proto exception 2019-10-13 20:48:54 +05:30
Saurabh
c64dece0dd feat: allow custom imap port (#8305)
* feat: allow custom imap port

* fix: use default port if not specified

* fix: pop3 port

* fix: common code to set the incomming port

* fix: codacy
2019-09-25 23:04:05 +00:00
Suraj Shetty
3eb6a22989
fix: Remove unwanted str() 2019-08-21 13:28:14 +05:30
Ashish Shah
4c7cbd6d7a
Update receive.py 2019-08-21 12:01:06 +05:30
Ashish Shah
b8803a51ad
Update receive.py 2019-08-19 18:34:52 +05:30
Ashish Shah
921788474e
Update receive.py
+existing code, works fine in python 2.7
+in python 3 it breaks
+In python 3 there is change in chardet module and hence the error
+convert-string-to-bytes-in-python-3
+this is also fixed in v11-hotfix branch
2019-07-31 10:17:19 +05:30
Saurabh
6d9fa54f0b Merge branch 'master' into develop 2019-03-20 14:30:48 +05:30
Aleksas Pielikis
70ac6f5c4e fix(email): Fixed py3 email byte-content decoding (#7058)
* Email decode from bytes fix added.

* Correction according to comments.
2019-03-18 13:08:06 +05:30
Sagar Vora
56a221573b Merge branch 'master' into develop 2019-02-19 17:52:19 +05:30
Rushabh Mehta
572edb08ba fix(email): default UIDVALIDITY to 0 2019-02-19 14:28:14 +05:30
Saurabh
d1bed88f3f Merge branch 'staging' into develop 2019-01-15 19:14:06 +05:30
Rohit Waghchaure
59549eb9df [Fix] Emails are not fetching 2019-01-10 16:01:36 +05:30
Chinmay Pai
75c7992557
file-api: add new test, fix minor bugs and code indentation
Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-09-21 13:40:25 +05:30
Chinmay Pai
91aff48a19
file-api: fix email test and improve file saving logic
Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-09-20 15:40:04 +05:30
Chinmay Pai
5bd66f134d
file-api: add improvements to save() api
file can now be saved by calling save() on the file object instance

Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-09-13 09:46:48 +05:30
Chinmay Pai
6eca292e1a
[3/3] file-api: code migration
migrate api from file_manager.py to file.py

Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-09-06 01:18:21 +05:30
Chinmay Pai
22ba310aaf
[2/3] file-api: code migration
migrate api from file_manager.py to file.py

Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-09-03 18:04:45 +05:30
Chinmay Pai
16a99f5472
[1/3] file-api: code migration
migrate api from file_manager.py to file.py

Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-08-31 01:55:15 +05:30
Benji
aee86f7bc0 python3 minor bugfix (#5988)
* Update receive.py

* Update receive.py

* Update receive.py
2018-08-22 11:01:03 +05:30
Benji
0330499bb9 Fixes error (#5902)
Fixes "TypeError: cannot use a string pattern on a bytes-like object"
2018-08-07 14:44:40 +05:30
Rushabh Mehta
aef1046b1f
[email] remove style from email so it does not mess up desk (#5860)
* [email] remove style from email so it does not mess up desk

* [fix] tests

* [fix] image parsing, #savedbyatestcase

* [fix] timeout issues in test

* [fix] timeout issues in test
2018-07-24 17:00:14 +05:30
Rushabh Mehta
8488acf300
[fix] receive.py (#5369) 2018-04-05 16:35:43 +05:30
Achilles Rasquinha
bc702c6c00 bytes vs strings 2018-03-08 20:17:18 +05:30
Achilles Rasquinha
d62c586fb2 [FIX] fix sytntax 2018-03-08 18:12:19 +05:30
Achilles Rasquinha
4b2e182915 [FIX] safe_encode 2018-03-08 18:09:57 +05:30
Achilles Rasquinha
59d3986290 [FIX] safe decode for 3 2018-03-08 17:25:27 +05:30
Achilles Rasquinha
d1e38d21c2 [FIX] safe decode for 3 2018-03-08 17:18:38 +05:30
Achilles Rasquinha
93a3921f1d [FIX] safe decode for 3 2018-03-08 17:11:52 +05:30
Achilles Rasquinha
97963119a5 email parse content to unicode 2018-03-08 16:35:02 +05:30
Aditya Hase
e6bd1e4995 Replaced all instances of 'unicode' with 'six.text_type' (#3825) 2017-08-02 16:57:39 +05:30