forked from Silverfish/proton-bridge
GODT-876 Set default from if empty for importing draft
This commit is contained in:
@ -118,12 +118,20 @@ func (p *PMAPIProvider) transferDraft(rules transferRules, progress *Progress, m
|
||||
progress.messageImported(msg.ID, importedID, err)
|
||||
}
|
||||
|
||||
func (p *PMAPIProvider) importDraft(msg Message, globalMailbox *Mailbox) (string, error) {
|
||||
func (p *PMAPIProvider) importDraft(msg Message, globalMailbox *Mailbox) (string, error) { //nolint[funlen]
|
||||
message, attachmentReaders, err := p.parseMessage(msg)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to parse message")
|
||||
}
|
||||
|
||||
if message.Sender == nil {
|
||||
mainAddress := p.client().Addresses().Main()
|
||||
message.Sender = &mail.Address{
|
||||
Name: mainAddress.DisplayName,
|
||||
Address: mainAddress.Email,
|
||||
}
|
||||
}
|
||||
|
||||
// Trying to encrypt an encrypted draft will return an error;
|
||||
// users are forbidden to import messages encrypted with foreign keys to drafts.
|
||||
if message.IsEncrypted() {
|
||||
|
||||
24
test/features/ie/transfer/import_draft.feature
Normal file
24
test/features/ie/transfer/import_draft.feature
Normal file
@ -0,0 +1,24 @@
|
||||
Feature: Import from EML files
|
||||
Background:
|
||||
Given there is connected user "user"
|
||||
|
||||
Scenario: Import draft without from fallbacks to primary address
|
||||
Given there is EML file "Drafts/one.eml"
|
||||
"""
|
||||
Subject: no from yet
|
||||
To: Internal Bridge <test@protonmail.com>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
|
||||
hello
|
||||
|
||||
"""
|
||||
When user "user" imports local files with rules
|
||||
| source | target |
|
||||
| Drafts | Drafts |
|
||||
Then progress result is "OK"
|
||||
And transfer exported 1 messages
|
||||
And transfer imported 1 messages
|
||||
And transfer failed for 0 messages
|
||||
And API mailbox "Drafts" for "user" has messages
|
||||
| from | to | subject |
|
||||
| [userAddress] | test@protonmail.com | no from yet |
|
||||
Reference in New Issue
Block a user