Skip to content

Message interface #31

@EtienneBruines

Description

@EtienneBruines

I would like to discuss https://github.com/alienscience/imapsrv/blob/fetch/mailstore.go#L64-L74 :

// An IMAP message
type Message interface {
    // Get the message flags
    Flags() (uint8, error)
    // Get the date of the message as known by the server
    InternalDate() (time.Time, error)
    // Get the size of the message in bytes
    Size() (uint32, error)
    // Get a reader to access the message content
    Reader() (MessageReader, error)
}

The last one, Reader(), reads the entire message (including attachments). I can imagine one storing the headers separately from the actual body. Or in case of a multipart message, the attachments (because they are often much larger than the textual message) at another server (i.e. OpenStack Swift). Then it would be nice to be able to skip those (since most DBMS use transactions, having an io.Seeker for the entire message, isn't always an option - it's either loading it in the memory all at once, or starting another transaction to load something else). The current implementation (branch fetch), allows only for the first scenario.

As I read in https://tools.ietf.org/html/rfc3501#section-6.4.5, there are multiple attributes that can be fetched:

  • BODY
  • BODY[
    ]<>
  • BODY.PEEK[
    ]<>
  • BODYSTRUCTURE
  • ENVELOPE
  • FLAGS
  • INTERNALDATE
  • RFC822
  • RFC822.HEADER
  • RFC822.SIZE
  • RFC822.TEXT
  • UID

Would it be doable if we made the interface use these instead? That way the separate parts of the message could be stored anywhere the user pleases.

type Message interface {
    GetBody() (io.Reader, error)
    GetPartialBody(section uint8, setSeen bool) (io.Reader, error)
    GetBodyStructure() (io.Reader, error)
    GetEnvelope() (io.Reader, error)
    GetFlags() ([]uint8, error)
    GetInternalDate (time.Time, error)
    GetRFC822Body() (io.Reader, error)
    GetRFC822Header() (io.Reader, error)
    GetRFC822Size() (uint64, error)
    GetRFC822Text() (io.Reader, error)
    GetUID() (int32, error)
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions