Skip to content

Commit

Permalink
feat(GODT-3199): log ids for fetched body.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuthix committed Feb 26, 2024
1 parent 70bd825 commit b341259
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion imap/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package imap

// ShortID return a string containing a short version of the given ID. Use only for debug display.
func ShortID(id string) string {
const l = 12
const l = 36

if len(id) < l {
return id
Expand Down
5 changes: 4 additions & 1 deletion internal/state/mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type AppendOnlyMailbox interface {

func newMailbox(mbox *db.Mailbox, state *State, snap *snapshot) *Mailbox {
id := db.NewMailboxIDPair(mbox)

return &Mailbox{
id: id,
name: mbox.Name,
Expand All @@ -52,7 +53,9 @@ func newMailbox(mbox *db.Mailbox, state *State, snap *snapshot) *Mailbox {
selected: snap != nil,
readOnly: state.ro,
snap: snap,
log: logrus.WithField("pkg", "gluon/state/mailbox").WithField("id", id),
log: logrus.
WithField("pkg", "gluon/state/mailbox").
WithField("mboxID", id.String()),
}
}

Expand Down
8 changes: 8 additions & 0 deletions internal/state/mailbox_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (m *Mailbox) Fetch(ctx context.Context, cmd *command.Fetch, ch chan respons
needsLiteral bool
wantUID bool
setSeen bool
isBodyFetch bool
)

for _, attribute := range cmd.Attributes {
Expand All @@ -53,11 +54,13 @@ func (m *Mailbox) Fetch(ctx context.Context, cmd *command.Fetch, ch chan respons
case *command.FetchAttributeRFC822:
setSeen = true
needsLiteral = true
isBodyFetch = true

operations = append(operations, fetchRFC822)
case *command.FetchAttributeRFC822Text:
setSeen = true
needsLiteral = true
isBodyFetch = true

operations = append(operations, fetchRFC822Text)
case *command.FetchAttributeRFC822Header:
Expand All @@ -78,6 +81,7 @@ func (m *Mailbox) Fetch(ctx context.Context, cmd *command.Fetch, ch chan respons
operations = append(operations, fetchBodyStructure)
case *command.FetchAttributeBodySection:
needsLiteral = true
isBodyFetch = true

if !attribute.Peek {
setSeen = true
Expand Down Expand Up @@ -162,6 +166,10 @@ func (m *Mailbox) Fetch(ctx context.Context, cmd *command.Fetch, ch chan respons
snapMessages[i].snapMsg = nil
}

if isBodyFetch {
m.log.WithField("UID", msg.UID).WithField("messageID", msg.ID.String()).Debug("Fetch Body")
}

ch <- response.Fetch(msg.Seq).WithItems(items...)

return nil
Expand Down

0 comments on commit b341259

Please sign in to comment.