jmap: expose ID::Valid() function

A consumer cannot be aware of whether or not an ID is valid otherwise.

Signed-off-by: Tristan Partin <tristan@partin.io>
Fix an issue with `isAscending`

According to the spec, it defaults to true. But since `omitempty` was set, the absence == the zero value == false, so it ends up true in the API.
client: allow upload/download with a context

Add new UploadWithContext and DownloadWithContext methods to
jmap.Client to allow cancelling these requests.

Signed-off-by: Robin Jarry <robin@jarry.cc>
mail/emailsubmission: fix Envelope.MailFrom JSON property

The JMAP RFC specifies this property with uppercase "F". Having it
lowercase here caused the server to fail to detect it and return an
error when trying to send an email with explicitly provided envelope.

Signed-off-by: Karel Balej <balejk@matfyz.cz>
treewide: strip RFC comments

RFC text is subject to a specific license which does not allow
modification of content. Remove all comments that are quoted from RFCs
and replace them with links to the RFCs themselves.

Signed-off-by: Robin Jarry <robin@jarry.cc>
mailbox: reword comments

For copyright reasons, RFC text cannot be quoted and modified. Reword
all comments that come from RFCs.

Signed-off-by: Robin Jarry <robin@jarry.cc>
jmap: reword comments

RFC text cannot be quoted and modified, per copyright. Reword comments
that come from RFCs

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
vacationresponse: fix infinite recursion

Fix infinite recursion when marshaling a VacationResponse object to
JSON. This type alias was forgotten.

Fixes: 821d0924a12e ("dates: force UTC timezone")
Signed-off-by: Robin Jarry <robin@jarry.cc>
dates: force UTC timezone

In the RFC, it is stated that all (or almost all) dates should be
"UTCDate" (e.g. in the UTC timezone and formatted with a trailing "Z").

Convert the dates to use the UTC timezone when required before
marshaling to JSON. Create type aliases to be able to call
json.Marshal() from MarshalJSON() without a recursion error.

Link: https://www.rfc-editor.org/rfc/rfc8620.html#section-1.4
Link: https://www.rfc-editor.org/rfc/rfc8621.html#section-4.4.1
Link: https://choly.ca/post/go-json-marshalling/
Signed-off-by: Robin Jarry <robin@jarry.cc>
Revert "client: use decoder for client.Do"

This reverts commit ec1d23ed70ef0eb6c357d1bc6dee699c018b226b.
treewide: update license and rfc references

The reference to draft-ietf-jmap-core-17 is outdated. Add reference to
the official RFCs.

Signed-off-by: Robin Jarry <robin@jarry.cc>
client: use decoder for client.Do

This allows streaming decoding as opposed to reading the entire response
and then unmarshaling

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
account: add ID field

Add an ID field to the Account struct to serve as a helper for clients.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
email/query: change type of Filter to Filter interface

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
mail/emailsubmission: use mail uri in all calls

Some emailsubmission calls require the mail capability themselves. Add
this URI to all calls for best compatibility

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
fix: change all time.Time to pointers

Change all time.Time references to pointers so their 0 value is nil

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
id: remove check for valid id

Remove check for valid jmap ID when marshalling JSON. This can cause
errors when using reference IDs ("#id")

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
mail/emailsubmission: change type on Capability

Change type on the SubmissionsExtension key of the EmailSubmission
capability object. The specification says this should be an object where
keys are strings, and values are arrays of strings. Fastmail returns an
empty array.

Change to json.RawMessage to enable compatibility until Fastmail fixes
their API.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
email/bodyValue: fix camel casing

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>