Skip to content

Conversation

dejanstrbac
Copy link
Contributor

No description provided.

Copy link
Owner

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this implements only part of APPENDLIMIT: this is missing the STATUS extension.

// DiscloseLimit indicates whether the limit should be advertised in the CAPABILITY
// response. If false, only "APPENDLIMIT" will be listed, without the actual limit.
// If true, "APPENDLIMIT=<limit>" will be listed.
DiscloseLimit() bool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this method? Servers can already reject literals which are too large in APPEND without advertising a limit (by returning an error).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPENDLIMIT capability can be advertised as APPENDLIMIT only or with explicit limit APPENDLIMIT=. In first you have to try to discover the limit while in the second you know before you try. The method allows to server to configure whether it will advertise it or not.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'm not sure I'm following. If APPENDLIMIT is listed in Caps, then we already know that the server wants to disclose the limit?

How about the following:

  • If AppendLimit is not listed in Caps, never advertise AppendLimit
  • If AppendLimit is listed in Caps:
    • If SessionAppendLimit is implemented and returns a non-zero value, advertise APPENDLIMIT=n
    • Otherwise, advertise APPENDLIMIT without a value

} else {
caps = append(caps, imap.CapAppendLimit)
}
} else if limit, ok := available.AppendLimit(); ok {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds two ways to set the global limit, either with a SessionAppendLimit, either with manual string formatting in Caps. I'd prefer to keep only the former.

Comment on lines 89 to 90
// Capabilities which require backend support and apply to both
// IMAP4rev1 and IMAP4rev2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this comment next to the addAvailableCaps list below?

@@ -86,6 +88,21 @@ func (c *Conn) availableCaps() []imap.Cap {

// Capabilities which require backend support and apply to both
// IMAP4rev1 and IMAP4rev2
if appendLimitSession, ok := c.session.(SessionAppendLimit); ok {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the RFC, we should only advertise a limit in the authenticated state.

}

// NewUserSessionWithAppendLimit creates a new user session with a custom append limit.
func NewUserSessionWithAppendLimit(user *User, appendLimit uint32, discloseLimit bool) *UserSession {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep this simple and only have a single global append limit in imapmemserver?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants