forked from Silverfish/proton-bridge
fix: better draft detection for parentID
This commit is contained in:
@ -30,6 +30,7 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
||||
|
||||
### Fixed
|
||||
* Use correct binary name when finding location of addcert.scpt
|
||||
* Correctly detect if a message is a draft even if does not have DraftLabel
|
||||
|
||||
## [v1.2.6] Donghai - beta (2020-03-31)
|
||||
|
||||
|
||||
@ -382,7 +382,7 @@ func (su *smtpUser) handleReferencesHeader(m *pmapi.Message) (draftID, parentID
|
||||
}
|
||||
metadata, _, _ := su.client.ListMessages(filter)
|
||||
for _, m := range metadata {
|
||||
if isDraft(m) {
|
||||
if m.IsDraft() {
|
||||
draftID = m.ID
|
||||
} else {
|
||||
parentID = m.ID
|
||||
@ -411,15 +411,6 @@ func (su *smtpUser) handleReferencesHeader(m *pmapi.Message) (draftID, parentID
|
||||
return draftID, parentID
|
||||
}
|
||||
|
||||
func isDraft(m *pmapi.Message) bool {
|
||||
for _, labelID := range m.LabelIDs {
|
||||
if labelID == pmapi.DraftLabel {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (su *smtpUser) handleSenderAndRecipients(m *pmapi.Message, addr *pmapi.Address, from string, to []string) (err error) {
|
||||
from = pmapi.ConstructAddress(from, addr.Email)
|
||||
|
||||
|
||||
@ -219,6 +219,13 @@ func (m *Message) UnmarshalJSON(b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsDraft returns whether the message should be considered to be a draft.
|
||||
// A draft is complicated. It might have pmapi.DraftLabel but it might not.
|
||||
// The real API definition of IsDraft is that it is neither sent nor received -- we should use that here.
|
||||
func (m *Message) IsDraft() bool {
|
||||
return (m.Flags & (FlagReceived | FlagSent)) == 0
|
||||
}
|
||||
|
||||
func (m *Message) IsBodyEncrypted() bool {
|
||||
trimmedBody := strings.TrimSpace(m.Body)
|
||||
return strings.HasPrefix(trimmedBody, MessageHeader) &&
|
||||
|
||||
Reference in New Issue
Block a user