Documentation
¶
Index ¶
- Constants
- type Address
- type Capability
- type Changes
- type ChangesResponse
- type DeliveryStatus
- type EmailSubmission
- type Envelope
- type Filter
- type FilterCondition
- type FilterOperator
- type Get
- type GetResponse
- type Query
- type QueryChanges
- type QueryChangesResponse
- type QueryResponse
- type Set
- type SetResponse
- type SortComparator
Constants ¶
const URI jmap.URI = "urn:ietf:params:jmap:submission"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
// The email address
Email string `json:"email,omitempty"`
// Parameters to send with the email submission, if any SMTP extensions
// are used
Parameters interface{} `json:"parameters,omitempty"`
}
type Capability ¶
type Capability struct {
// The maximum number of seconds the server supports for delayed
// sending. A value of 0 indicates delayed sending is not supported
MaxDelayedSend uint64 `json:"maxDelayedSend,omitempty"`
// The set of SMTP submission extensions supported by the server, which
// the client may use when creating an EmailSubmission object (see
// Section 7). Each key in the object is the ehlo-name, and the value is
// a list of ehlo-args.
SubmissionExtensions map[string]string `json:"submissionExtensions,omitempty"`
}
The EmailSubmission Capability
func (*Capability) New ¶
func (m *Capability) New() jmap.Capability
func (*Capability) URI ¶
func (m *Capability) URI() jmap.URI
type Changes ¶
type Changes struct {
// The id of the account to use.
Account jmap.ID `json:"accountId,omitempty"`
// The current state of the client. This is the string that was
// returned as the state argument in the Foo/get response. The server
// will return the changes that have occurred since this state.
SinceState string `json:"sinceState,omitempty"`
// The maximum number of ids to return in the response. The server MAY
// choose to return fewer than this value but MUST NOT return more. If
// not given by the client, the server may choose how many to return.
// If supplied by the client, the value MUST be a positive integer
// greater than 0. If a value outside of this range is given, the
// server MUST reject the call with an invalidArguments error.
MaxChanges uint64 `json:"maxChanges,omitempty"`
}
This is a standard “/changes” method as described in [@!RFC8620], Section 5.2.
type ChangesResponse ¶
type ChangesResponse struct {
// The id of the account used for the call.
Account jmap.ID `json:"accountId,omitempty"`
// This is the sinceState argument echoed back; it’s the state from
// which the server is returning changes.
OldState string `json:"oldState,omitempty"`
// This is the state the client will be in after applying the set of
// changes to the old state.
NewState string `json:"newState,omitempty"`
// If true, the client may call Foo/changes again with the newState
// returned to get further updates. If false, newState is the current
// server state.
HasMoreChanges bool `json:"hasMoreChanges,omitempty"`
// An array of ids for records that have been created since the old
// state.
Created []jmap.ID `json:"created,omitempty"`
// An array of ids for records that have been updated since the old
// state.
Updated []jmap.ID `json:"updated,omitempty"`
// An array of ids for records that have been destroyed since the old
// state.
Destroyed []jmap.ID `json:"destroyed,omitempty"`
}
This is a standard “/changes” method as described in [@!RFC8620], Section 5.2.
type DeliveryStatus ¶
type DeliveryStatus struct {
// The SMTP reply returned for the recipient
SMTPReply string `json:"smtpReply,omitempty"`
// Represents whether the message has been successfully delivered to the
// recipient. Will be one of:
// - "queued": In a local mail queue
// - "yes": Delivered
// - "no": Delivery failed
// - "unknown": Final delivery status is unknown
Delivered string `json:"delivered,omitempty"`
// Whether the message has been displayed by the recipient. One of:
// - "unknown"
// - "yes"
Displayed string `json:"displayed,omitempty"`
}
type EmailSubmission ¶
type EmailSubmission struct {
// The ID of the [EmailSubmission]
//
// immutable;server-set
ID jmap.ID `json:"id,omitempty"`
// The ID of the Identity to associate with this submission
//
// immutable
IdentityID jmap.ID `json:"identityId,omitempty"`
// The ID of the Email to send
//
// immutable
EmailID jmap.ID `json:"emailId,omitempty"`
// The Thread ID of the Email to send
//
// immutable;server-set
ThreadID jmap.ID `json:"threadId,omitempty"`
// The Envelope used for SMTP
//
// immutable
Envelope *Envelope `json:"envelope,omitempty"`
// The date the submission was/will be released for delivery
//
// immutable;server-set
SendAt time.Time `json:"sendAt,omitempty"`
// A status indicating if the send can be undone. One of:
// - "pending": it may be possible to cancel
// - "final": the message has been sent
// - "canceled": the submission was canceled
//
// If this is "pending", a client can attempt to cancel by issuing a set
// method with this set to canceled
UndoStatus string `json:"undoStatus,omitempty"`
// The delivery status for each recipient
DeliveryStatus map[string]*DeliveryStatus `json:"deliveryStatus,omitempty"`
// A list of blob IDs for DSNs received for this submission
//
// server-set
DSNBlobIDs []jmap.ID `json:"dsnBlobIds,omitempty"`
// A list of blob IDs for MDNs received for this submission
//
// server-set
MDNBlobIDs []jmap.ID `json:"mdnBlobIds,omitempty"`
}
type FilterCondition ¶
type FilterCondition struct {
// identityIds field must be in this list to match
IdentityIDs []jmap.ID `json:"identityIds,omitempty"`
// emailId field must be in this list to match
EmailIDs []jmap.ID `json:"emailIds,omitempty"`
// threadId field must be in this list to match
ThreadIDs []jmap.ID `json:"threadIds,omitempty"`
// The undoStatus property must exactly match this to match
UndoStatus string `json:"undoStatus,omitempty"`
// UTC. The sendAt property must be before this time to match
Before *time.Time `json:"before,omitempty"`
// UTC. The sendAt property must be after this time to match
After *time.Time `json:"after,omitempty"`
}
FilterCondition is an interface that represents FilterCondition objects. A filter condition object can be either a named struct, ie MailboxFilterConditionName, or a MailboxFilter itself. MailboxFilters can be used to create complex filtering ie return mailboxes which are subscribed and NOT named Inbox
type FilterOperator ¶
type FilterOperator struct {
// This MUST be one of the following strings: “AND” / “OR” / “NOT”
Operator jmap.Operator `json:"operator,omitempty"`
// The conditions to evaluate against each record.
Conditions []Filter `json:"conditions,omitempty"`
}
Determines the set of EmailSubmissions returned in the results. If null, all objects in the account of this type are included in the results.
type Get ¶
type Get struct {
// The id of the account to use.
Account jmap.ID `json:"accountId,omitempty"`
// The ids of the Foo objects to return. If null, then all records of
// the data type are returned, if this is supported for that data type
// and the number of records does not exceed the maxObjectsInGet limit.
IDs []jmap.ID `json:"ids,omitempty"`
// If supplied, only the properties listed in the array are returned
// for each Foo object. If null, all properties of the object are
// returned. The id property of the object is always returned, even if
// not explicitly requested. If an invalid property is requested, the
// call MUST be rejected with an invalidArguments error.
Properties []string `json:"properties,omitempty"`
}
This is a standard “/get” method as described in [@!RFC8620], Section 5.1.
type GetResponse ¶
type GetResponse struct {
// The id of the account used for the call.
Account jmap.ID `json:"accountId,omitempty"`
// A (preferably short) string representing the state on the server for
// all the data of this type in the account (not just the objects
// returned in this call). If the data changes, this string MUST
// change. If the Foo data is unchanged, servers SHOULD return the same
// state string on subsequent requests for this data type.
//
// When a client receives a response with a different state string to a
// previous call, it MUST either throw away all currently cached
// objects for the type or call Foo/changes to get the exact changes.
State string `json:"state,omitempty"`
// An array of the Foo objects requested. This is the empty array
// if no objects were found or if the ids argument passed in was also
// an empty array. The results MAY be in a different order to the ids
// in the request arguments. If an identical id is included more than
// once in the request, the server MUST only include it once in either
// the list or the notFound argument of the response.
//
// Each specification must define it's own List property
List []*EmailSubmission `json:"list,omitempty"`
// This array contains the ids passed to the method for records that do
// not exist. The array is empty if all requested ids were found or if
// the ids argument passed in was either null or an empty array.
NotFound []jmap.ID `json:"notFound,omitempty"`
}
This is a standard “/get” method as described in [@!RFC8620], Section 5.1.
type Query ¶
type Query struct {
// The id of the account to use.
Account jmap.ID `json:"accountId,omitempty"`
// Determines the set of Foos returned in the results. If null, all
// objects in the account of this type are included in the results.
//
// Each implementation must implement it's own Filter
Filter Filter `json:"filter,omitempty"`
// Lists the names of properties to compare between two Foo records,
// and how to compare them, to determine which comes first in the sort.
// If two Foo records have an identical value for the first comparator,
// the next comparator will be considered, and so on. If all
// comparators are the same (this includes the case where an empty
// array or null is given as the sort argument), the sort order is
// server dependent, but it MUST be stable between calls to Foo/query.
//
// Each implementation must define it's own Sort property. The
// SortComparator object can be used as a basis
Sort []*SortComparator `json:"sort,omitempty"`
// The zero-based index of the first id in the full list of results to
// return.
//
// If a negative value is given, it is an offset from the end of the
// list. Specifically, the negative value MUST be added to the total
// number of results given the filter, and if still negative, it’s
// clamped to 0. This is now the zero-based index of the first id to
// return.
//
// If the index is greater than or equal to the total number of objects
// in the results list, then the ids array in the response will be
// empty, but this is not an error.
Position int64 `json:"position,omitempty"`
// A Foo id. If supplied, the position argument is ignored. The index
// of this id in the results will be used in combination with the
// anchorOffset argument to determine the index of the first result to
// return (see below for more details).
//
// If an anchor argument is given, the anchor is looked for in the
// results after filtering and sorting. If found, the anchorOffset is
// then added to its index. If the resulting index is now negative, it
// is clamped to 0. This index is now used exactly as though it were
// supplied as the position argument. If the anchor is not found, the
// call is rejected with an anchorNotFound error.
//
// If an anchor is specified, any position argument supplied by the
// client MUST be ignored. If no anchor is supplied, any anchorOffset
// argument MUST be ignored.
//
// A client can use anchor instead of position to find the index of an
// id within a large set of results.
Anchor jmap.ID `json:"anchor,omitempty"`
// The index of the first result to return relative to the index of the
// anchor, if an anchor is given. This MAY be negative. For example, -1
// means the Foo immediately preceding the anchor is the first result
// in the list returned (see below for more details).
AnchorOffset int64 `json:"anchorOffset,omitempty"`
// The maximum number of results to return. If null, no limit presumed.
// The server MAY choose to enforce a maximum limit argument. In this
// case, if a greater value is given (or if it is null), the limit is
// clamped to the maximum; the new limit is returned with the response
// so the client is aware. If a negative value is given, the call MUST
// be rejected with an invalidArguments error.
Limit uint64 `json:"limit,omitempty"`
// Does the client wish to know the total number of results in the
// query? This may be slow and expensive for servers to calculate,
// particularly with complex filters, so clients should take care to
// only request the total when needed.
CalculateTotal bool `json:"calculateTotal,omitempty"`
}
This is a standard “/query” method as described in [@!RFC8620], Section 5.5, but with the following additional request argument: sortAsTree, filterAsTree
type QueryChanges ¶
type QueryChanges struct {
// The id of the account to use.
Account jmap.ID `json:"accountId,omitempty"`
// The filter argument that was used with Foo/query.
//
// Each implementation must supply it's own Filter property
Filter Filter `json:"filter,omitempty"`
// The sort argument that was used with Foo/query.
//
// Each implementation must supply it's own Sort property
Sort []*SortComparator `json:"sort,omitempty"`
// The current state of the query in the client. This is the string
// that was returned as the queryState argument in the Foo/query
// response with the same sort/filter. The server will return the
// changes made to the query since this state.
SinceQueryState string `json:"sinceQueryState,omitempty"`
// The maximum number of changes to return in the response. See error
// descriptions below for more details.
MaxChanges uint64 `json:"maxChanges,omitempty"`
// The last (highest-index) id the client currently has cached from the
// query results. When there are a large number of results, in a common
// case, the client may have only downloaded and cached a small subset
// from the beginning of the results. If the sort and filter are both
// only on immutable properties, this allows the server to omit changes
// after this point in the results, which can significantly increase
// efficiency. If they are not immutable, this argument is ignored.
UpToID jmap.ID `json:"upToId,omitempty"`
// Does the client wish to know the total number of results now in the
// query? This may be slow and expensive for servers to calculate,
// particularly with complex filters, so clients should take care to
// only request the total when needed.
CalculateTotal bool `json:"calculateTotal,omitempty"`
}
func (*QueryChanges) Name ¶
func (m *QueryChanges) Name() string
func (*QueryChanges) Requires ¶
func (m *QueryChanges) Requires() []jmap.URI
type QueryChangesResponse ¶
type QueryChangesResponse struct {
// The id of the account used for the call.
Account jmap.ID `json:"accountId,omitempty"`
// This is the sinceQueryState argument echoed back; that is, the state
// from which the server is returning changes.
OldQueryState string `json:"oldQueryState,omitempty"`
// This is the state the query will be in after applying the set of
// changes to the old state.
NewQueryState string `json:"newQueryState,omitempty"`
// The id for every Foo that was in the query results in the old state
// and that is not in the results in the new state.
//
// If the server cannot calculate this exactly, the server MAY return
// the ids of extra Foos in addition that may have been in the old
// results but are not in the new results.
//
// If the sort and filter are both only on immutable properties and an
// upToId is supplied and exists in the results, any ids that were
// removed but have a higher index than upToId SHOULD be omitted.
//
// If the filter or sort includes a mutable property, the server MUST
// include all Foos in the current results for which this property may
// have changed. The position of these may have moved in the results,
// so must be reinserted by the client to ensure its query cache is
// correct.
Removed []jmap.ID `json:"removed,omitempty"`
// The id and index in the query results (in the new state) for every
// Foo that has been added to the results since the old state AND every
// Foo in the current results that was included in the removed array
// (due to a filter or sort based upon a mutable property).
//
// If the sort and filter are both only on immutable properties and an
// upToId is supplied and exists in the results, any ids that were
// added but have a higher index than upToId SHOULD be omitted.
//
// The array MUST be sorted in order of index, with the lowest index
// first.
Added []*jmap.AddedItem `json:"added,omitempty"`
}
type QueryResponse ¶
type QueryResponse struct {
// The id of the account used for the call.
Account jmap.ID `json:"accountId,omitempty"`
// A string encoding the current state of the query on the server. This
// string MUST change if the results of the query (i.e., the matching
// ids and their sort order) have changed. The queryState string MAY
// change if something has changed on the server, which means the
// results may have changed but the server doesn’t know for sure.
//
// The queryState string only represents the ordered list of ids that
// match the particular query (including its sort/filter). There is no
// requirement for it to change if a property on an object matching the
// query changes but the query results are unaffected (indeed, it is
// more efficient if the queryState string does not change in this
// case). The queryState string only has meaning when compared to
// future responses to a query with the same type/sort/filter or when
// used with /queryChanges to fetch changes.
//
// Should a client receive back a response with a different queryState
// string to a previous call, it MUST either throw away the currently
// cached query and fetch it again (note, this does not require
// fetching the records again, just the list of ids) or call
// Foo/queryChanges to get the difference.
QueryState string `json:"queryState,omitempty"`
// This is true if the server supports calling Foo/queryChanges with
// these filter/sort parameters. Note, this does not guarantee that the
// Foo/queryChanges call will succeed, as it may only be possible for a
// limited time afterwards due to server internal implementation
// details.
CanCalculateChanges bool `json:"canCalculateChanges,omitempty"`
// The zero-based index of the first result in the ids array within the
// complete list of query results.
Position uint64 `json:"position,omitempty"`
// The list of ids for each Foo in the query results, starting at the
// index given by the position argument of this response and continuing
// until it hits the end of the results or reaches the limit number of
// ids. If position is >= total, this MUST be the empty list.
IDs []jmap.ID `json:"ids,omitempty"`
// The total number of Foos in the results (given the filter). This
// argument MUST be omitted if the calculateTotal request argument is
// not true.
Total int64 `json:"total,omitempty"`
// The limit enforced by the server on the maximum number of results to
// return. This is only returned if the server set a limit or used a
// different limit than that given in the request.
Limit uint64 `json:"limit,omitempty"`
}
type Set ¶
type Set struct {
// The id of the account to use.
Account jmap.ID `json:"accountId,omitempty"`
// This is a state string as returned by the Foo/get method
// (representing the state of all objects of this type in the account).
// If supplied, the string must match the current state; otherwise, the
// method will be aborted and a stateMismatch error returned. If null,
// any changes will be applied to the current state.
IfInState string `json:"ifInState,omitempty"`
// A map of a creation id (a temporary id set by the client) to Foo
// objects, or null if no objects are to be created.
//
// The Foo object type definition may define default values for
// properties. Any such property may be omitted by the client.
//
// The client MUST omit any properties that may only be set by the
// server (for example, the id property on most object types).
Create map[jmap.ID]*EmailSubmission `json:"create,omitempty"`
// A map of an id to a Patch object to apply to the current Foo object
// with that id, or null if no objects are to be updated.
//
// A PatchObject is of type String[*] and represents an unordered set
// of patches. The keys are a path in JSON Pointer Format [@!RFC6901],
// with an implicit leading “/” (i.e., prefix each key with “/” before
// applying the JSON Pointer evaluation algorithm).
//
// All paths MUST also conform to the following restrictions; if there
// is any violation, the update MUST be rejected with an invalidPatch
// error:
//
// The pointer MUST NOT reference inside an array (i.e., you MUST
// NOT insert/delete from an array; the array MUST be replaced in
// its entirety instead). All parts prior to the last (i.e., the
// value after the final slash) MUST already exist on the object
// being patched. There MUST NOT be two patches in the PatchObject
// where the pointer of one is the prefix of the pointer of the
// other, e.g., “alerts/1/offset” and “alerts”.
//
// The value associated with each pointer determines how to apply that
// patch:
//
// If null, set to the default value if specified for this
// property; otherwise, remove the property from the patched
// object. If the key is not present in the parent, this a no-op.
// Anything else: The value to set for this property (this may be a
// replacement or addition to the object being patched).
//
// Any server-set properties MAY be included in the patch if their
// value is identical to the current server value (before applying the
// patches to the object). Otherwise, the update MUST be rejected with
// an invalidProperties SetError.
//
// This patch definition is designed such that an entire Foo object is
// also a valid PatchObject. The client may choose to optimise network
// usage by just sending the diff or may send the whole object; the
// server processes it the same either way.
Update map[jmap.ID]*jmap.Patch `json:"update,omitempty"`
// A list of ids for Foo objects to permanently delete, or null if no
// objects are to be destroyed.
Destroy []jmap.ID `json:"destroy,omitempty"`
// A map of EmailSubmission id to an object containing properties to
// update on the Email object referenced by the EmailSubmission if the
// create/update/destroy succeeds. (For references to EmailSubmissions
// created in the same “/set” invocation, this is equivalent to a
// creation-reference, so the id will be the creation id prefixed with
// a #.)
OnSuccessUpdateEmail map[jmap.ID]*jmap.Patch `json:"onSuccessUpdateEmail,omitempty"`
// A list of EmailSubmission ids for which the Email with the
// corresponding emailId should be destroyed if the
// create/update/destroy succeeds. (For references to EmailSubmission
// creations, this is equivalent to a creation-reference so the id will
// be the creation id prefixed with a #.)
OnSuccessDestroyEmail []jmap.ID `json:"onSuccessDestroyEmail,omitempty"`
}
This is a standard “/set” method as described in [@!RFC8620], Section 5.3, but with the following additional request argument: onDestroyRemoveEmails
type SetResponse ¶
type SetResponse struct {
// The id of the account used for the call.
Account jmap.ID `json:"accountId,omitempty"`
// The state string that would have been returned by Foo/get before
// making the requested changes, or null if the server doesn’t know
// what the previous state string was.
OldState string `json:"oldState,omitempty"`
// The state string that will now be returned by Foo/get.
NewState string `json:"newState,omitempty"`
// A map of the creation id to an object containing any properties of
// the created Foo object that were not sent by the client. This
// includes all server-set properties (such as the id in most object
// types) and any properties that were omitted by the client and thus
// set to a default by the server.
//
// This argument is null if no Foo objects were successfully created.
Created map[jmap.ID]*EmailSubmission `json:"created,omitempty"`
// The keys in this map are the ids of all Foos that were successfully
// updated.
//
// The value for each id is a Foo object containing any property that
// changed in a way not explicitly requested by the PatchObject sent to
// the server, or null if none. This lets the client know of any
// changes to server-set or computed properties.
//
// This argument is null if no Foo objects were successfully updated.
Updated map[jmap.ID]*EmailSubmission `json:"updated,omitempty"`
// An array of ids for records that have been destroyed since the old
// state.
Destroyed []jmap.ID `json:"destroyed,omitempty"`
// A map of ID to a SetError for each record that failed to be created
NotCreated map[jmap.ID]*jmap.SetError `json:"notCreated,omitempty"`
// A map of ID to a SetError for each record that failed to be updated
NotUpdated map[jmap.ID]*jmap.SetError `json:"notUpdated,omitempty"`
// A map of ID to a SetError for each record that failed to be destroyed
NotDestroyed map[jmap.ID]*jmap.SetError `json:"notDestroyed,omitempty"`
}
type SortComparator ¶
type SortComparator struct {
// The name of the property on the Foo objects to compare. Servers MUST
// support sorting by the following properties:
// - emailId
// - threadId
// - sentAt
Property string `json:"property,omitempty"`
// If true, sort in ascending order. If false, reverse the comparator’s
// results to sort in descending order.
IsAscending bool `json:"isAscending,omitempty"`
// The identifier, as registered in the collation registry defined in
// [@!RFC4790], for the algorithm to use when comparing the order of
// strings. The algorithms the server supports are advertised in the
// capabilities object returned with the Session object (see Section
// 2).
//
// If omitted, the default algorithm is server-dependent, but:
//
// It MUST be unicode-aware. It MAY be selected based on an
// Accept-Language header in the request (as defined in
// [@!RFC7231], Section 5.3.5), or out-of-band information about
// the user’s language/locale. It SHOULD be case insensitive where
// such a concept makes sense for a language/locale. Where the
// user’s language is unknown, it is RECOMMENDED to follow the
// advice in Section 5.2.3 of [@!RFC8264].
//
// The “i;unicode-casemap” collation [@!RFC5051] and the Unicode
// Collation Algorithm (http://www.unicode.org/reports/tr10/) are two
// examples that fulfil these criterion and provide reasonable
// behaviour for a large number of languages.
//
// When the property being compared is not a string, the collation
// property is ignored, and the following comparison rules apply based
// on the type. In ascending order:
//
// Boolean: false comes before true. Number: A lower number comes
// before a higher number. Date/UTCDate: The earlier date comes
// first.
Collation jmap.CollationAlgo `json:"collation,omitempty"`
}