mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
GODT-1146: Refactor header filtering
This commit is contained in:
@ -247,12 +247,7 @@ func (bs *BodyStructure) GetMailHeader() (header textproto.MIMEHeader, err error
|
||||
// GetMailHeaderBytes returns the bytes with main mail header.
|
||||
// Warning: It can contain extra lines or multipart comment.
|
||||
func (bs *BodyStructure) GetMailHeaderBytes(wholeMail io.ReadSeeker) (header []byte, err error) {
|
||||
info, err := bs.getInfo([]int{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
headerLength := info.Size - info.BSize
|
||||
return goToOffsetAndReadNBytes(wholeMail, 0, headerLength)
|
||||
return bs.GetSectionHeaderBytes(wholeMail, []int{})
|
||||
}
|
||||
|
||||
func goToOffsetAndReadNBytes(wholeMail io.ReadSeeker, offset, length int) ([]byte, error) {
|
||||
@ -279,6 +274,15 @@ func (bs *BodyStructure) GetSectionHeader(sectionPath []int) (header textproto.M
|
||||
return
|
||||
}
|
||||
|
||||
func (bs *BodyStructure) GetSectionHeaderBytes(wholeMail io.ReadSeeker, sectionPath []int) (header []byte, err error) {
|
||||
info, err := bs.getInfo(sectionPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
headerLength := info.Size - info.BSize
|
||||
return goToOffsetAndReadNBytes(wholeMail, info.Start, headerLength)
|
||||
}
|
||||
|
||||
// IMAPBodyStructure will prepare imap bodystructure recurently for given part.
|
||||
// Use empty path to create whole email structure.
|
||||
func (bs *BodyStructure) IMAPBodyStructure(currentPart []int) (imapBS *imap.BodyStructure, err error) {
|
||||
|
||||
Reference in New Issue
Block a user