GODT-1433: Do not save message to cache if it's a draft.

- remove: deprecated SetContentTypeAndHeader
- fix: write metada unit test
- change: do not cache body for Drafts
- change: do not cache body structure (header) for Drafts
- change: do not cache body size for Drafts
This commit is contained in:
Jakub
2021-11-24 16:53:36 +01:00
parent 7ce3529f5d
commit 6ed97a0347
5 changed files with 118 additions and 52 deletions

View File

@ -324,7 +324,7 @@ func clearNonMetadata(onlyMeta *pmapi.Message) {
// If there is stored message in metaBucket the size, header and MIMEType are
// not changed if already set. To change these:
// * size must be updated by Message.SetSize
// * contentType and header must be updated by Message.SetContentTypeAndHeader.
// * contentType and header must be updated by bodystructure.
func txUpdateMetadataFromDB(metaBucket *bolt.Bucket, onlyMeta *pmapi.Message, log *logrus.Entry) {
msgb := metaBucket.Get([]byte(onlyMeta.ID))
if msgb == nil {
@ -386,3 +386,13 @@ func (store *Store) deleteMessagesEvent(apiIDs []string) error {
return nil
})
}
func (store *Store) isMessageADraft(apiID string) bool {
msg, err := store.getMessageFromDB(apiID)
if err != nil {
store.log.WithError(err).Warn("Cannot decide wheather message is draff")
return false
}
return msg.IsDraft()
}