mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-06-16 11:58:52 -04:00
* adds pkg/jmap/jmap_integration_test.go
* uses ghcr.io/stalwartlabs/stalwart:v0.13.2-alpine
* can be disabled by setting one of the following environment
variables, in the same fashion as ca0493b28
- CI=woodpecker
- CI_SYSTEM_NAME=woodpecker
- USE_TESTCONTAINERS=false
* dependencies:
- bump github.com/go-test/deep from 1.1.0 to 1.1.1
- add github.com/cention-sany/utf7
- add github.com/dustinkirkland/golang-petname
- add github.com/emersion/go-imap/v2
- add github.com/emersion/go-message
- add github.com/emersion/go-sasl
- add github.com/go-crypt/crypt
- add github.com/go-crypt/x
- add github.com/gogs/chardet
- add github.com/inbucket/html2text
- add github.com/jhilleryerd/enmime/v2
- add github.com/ssor/bom
- add gopkg.in/loremipsum.v1
82 lines
2.6 KiB
Go
82 lines
2.6 KiB
Go
package imap
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// StatusResponseType is a generic status response type.
|
|
type StatusResponseType string
|
|
|
|
const (
|
|
StatusResponseTypeOK StatusResponseType = "OK"
|
|
StatusResponseTypeNo StatusResponseType = "NO"
|
|
StatusResponseTypeBad StatusResponseType = "BAD"
|
|
StatusResponseTypePreAuth StatusResponseType = "PREAUTH"
|
|
StatusResponseTypeBye StatusResponseType = "BYE"
|
|
)
|
|
|
|
// ResponseCode is a response code.
|
|
type ResponseCode string
|
|
|
|
const (
|
|
ResponseCodeAlert ResponseCode = "ALERT"
|
|
ResponseCodeAlreadyExists ResponseCode = "ALREADYEXISTS"
|
|
ResponseCodeAuthenticationFailed ResponseCode = "AUTHENTICATIONFAILED"
|
|
ResponseCodeAuthorizationFailed ResponseCode = "AUTHORIZATIONFAILED"
|
|
ResponseCodeBadCharset ResponseCode = "BADCHARSET"
|
|
ResponseCodeCannot ResponseCode = "CANNOT"
|
|
ResponseCodeClientBug ResponseCode = "CLIENTBUG"
|
|
ResponseCodeContactAdmin ResponseCode = "CONTACTADMIN"
|
|
ResponseCodeCorruption ResponseCode = "CORRUPTION"
|
|
ResponseCodeExpired ResponseCode = "EXPIRED"
|
|
ResponseCodeHasChildren ResponseCode = "HASCHILDREN"
|
|
ResponseCodeInUse ResponseCode = "INUSE"
|
|
ResponseCodeLimit ResponseCode = "LIMIT"
|
|
ResponseCodeNonExistent ResponseCode = "NONEXISTENT"
|
|
ResponseCodeNoPerm ResponseCode = "NOPERM"
|
|
ResponseCodeOverQuota ResponseCode = "OVERQUOTA"
|
|
ResponseCodeParse ResponseCode = "PARSE"
|
|
ResponseCodePrivacyRequired ResponseCode = "PRIVACYREQUIRED"
|
|
ResponseCodeServerBug ResponseCode = "SERVERBUG"
|
|
ResponseCodeTryCreate ResponseCode = "TRYCREATE"
|
|
ResponseCodeUnavailable ResponseCode = "UNAVAILABLE"
|
|
ResponseCodeUnknownCTE ResponseCode = "UNKNOWN-CTE"
|
|
|
|
// METADATA
|
|
ResponseCodeTooMany ResponseCode = "TOOMANY"
|
|
ResponseCodeNoPrivate ResponseCode = "NOPRIVATE"
|
|
|
|
// APPENDLIMIT
|
|
ResponseCodeTooBig ResponseCode = "TOOBIG"
|
|
)
|
|
|
|
// StatusResponse is a generic status response.
|
|
//
|
|
// See RFC 9051 section 7.1.
|
|
type StatusResponse struct {
|
|
Type StatusResponseType
|
|
Code ResponseCode
|
|
Text string
|
|
}
|
|
|
|
// Error is an IMAP error caused by a status response.
|
|
type Error StatusResponse
|
|
|
|
var _ error = (*Error)(nil)
|
|
|
|
// Error implements the error interface.
|
|
func (err *Error) Error() string {
|
|
var sb strings.Builder
|
|
fmt.Fprintf(&sb, "imap: %v", err.Type)
|
|
if err.Code != "" {
|
|
fmt.Fprintf(&sb, " [%v]", err.Code)
|
|
}
|
|
text := err.Text
|
|
if text == "" {
|
|
text = "<unknown>"
|
|
}
|
|
fmt.Fprintf(&sb, " %v", text)
|
|
return sb.String()
|
|
}
|