forked from Silverfish/proton-bridge
test: set sent label properly
This commit is contained in:
@ -523,14 +523,7 @@ func updateMessage(msgLog *logrus.Entry, message *pmapi.Message, updates *pmapi.
|
||||
message.LabelIDs = updates.LabelIDs
|
||||
} else {
|
||||
for _, added := range updates.LabelIDsAdded {
|
||||
hasLabel := false
|
||||
for _, l := range message.LabelIDs {
|
||||
if added == l {
|
||||
hasLabel = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasLabel {
|
||||
if !message.HasLabelID(added) {
|
||||
msgLog.WithField("added", added).Trace("Adding label to message")
|
||||
message.LabelIDs = append(message.LabelIDs, added)
|
||||
}
|
||||
|
||||
@ -241,6 +241,16 @@ func (m *Message) IsDraft() bool {
|
||||
return (m.Flags & (FlagReceived | FlagSent)) == 0
|
||||
}
|
||||
|
||||
// HasLabelID returns whether the message has the `labelID`.
|
||||
func (m *Message) HasLabelID(labelID string) bool {
|
||||
for _, l := range m.LabelIDs {
|
||||
if l == labelID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *Message) IsBodyEncrypted() bool {
|
||||
trimmedBody := strings.TrimSpace(m.Body)
|
||||
return strings.HasPrefix(trimmedBody, MessageHeader) &&
|
||||
|
||||
@ -81,11 +81,17 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
if err != nil {
|
||||
return internalError(err, "getting labels %s for %s", mailboxNames, account.Username())
|
||||
}
|
||||
|
||||
message := &pmapi.Message{
|
||||
MIMEType: "text/plain",
|
||||
LabelIDs: labelIDs,
|
||||
AddressID: account.AddressID(),
|
||||
}
|
||||
|
||||
if message.HasLabelID(pmapi.SentLabel) {
|
||||
message.Flags |= pmapi.FlagSent
|
||||
}
|
||||
|
||||
for n, cell := range messages.Rows[i].Cells {
|
||||
switch head[n].Value {
|
||||
case "from":
|
||||
|
||||
Reference in New Issue
Block a user