Documentation
¶
Index ¶
- Constants
- Variables
- func Delete(ctx context.Context, client api.DeleteItemAPI, messageID string) error
- func GetContent(ctx context.Context, client api.GetItemContentAPI, ...) (*storage.GetEmailContentResult, error)
- func Read(ctx context.Context, client api.UpdateItemAPI, messageID, action string) error
- func Reparse(ctx context.Context, client api.ReparseEmailAPI, messageID string) error
- func Trash(ctx context.Context, client api.UpdateItemAPI, messageID string) error
- func UnmarshalGSI(item map[string]dynamodbTypes.AttributeValue) (emailType, emailTime string, err error)
- func Untrash(ctx context.Context, client api.UpdateItemAPI, messageID string) error
- type CreateInput
- type CreateResult
- type Cursor
- type GSIIndex
- type GetResult
- type Input
- type Item
- type LastEvaluatedKey
- type ListInput
- type ListResult
- type OriginalMessageIDIndex
- type QueryInfo
- type RawEmailItem
- type SaveInput
- type SaveResult
- type SendResult
- type ThreadInfo
- type TimeIndex
- type Verdict
Constants ¶
const ( ShowTrashExclude = "exclude" ShowTrashInclude = "include" ShowTrashOnly = "only" )
const ( ActionRead = "read" ActionUnread = "unread" )
const (
DefaultPageSize int32 = 100
)
Variables ¶
var ( ErrInvalidInputToUnmarshal = errors.New("invalid input to unmarshal") ErrInvalidInputToDecode = errors.New("invalid input to decode") )
Functions ¶
func Delete ¶
Delete deletes an trashed email from DynamoDB and S3. This action won't be successful if it's not trashed.
func GetContent ¶ added in v1.4.0
func GetContent(ctx context.Context, client api.GetItemContentAPI, messageID, disposition, contentID string) (*storage.GetEmailContentResult, error)
Get returns the email
func UnmarshalGSI ¶ added in v1.6.0
func UnmarshalGSI(item map[string]dynamodbTypes.AttributeValue) (emailType, emailTime string, err error)
Types ¶
type CreateInput ¶
type CreateInput struct {
Input
GenerateText string `json:"generateText"` // on, off, or auto (default)
Send bool `json:"send"` // send email immediately
ReplyEmailID string `json:"replyEmailID"` // reply to an email, empty if not reply
}
CreateInput represents the input of create method
type CreateResult ¶
type CreateResult struct {
TimeIndex
Subject string `json:"subject"`
From []string `json:"from"`
To []string `json:"to"`
Cc []string `json:"cc"`
Bcc []string `json:"bcc"`
ReplyTo []string `json:"replyTo"`
Text string `json:"text"`
HTML string `json:"html"`
ThreadID string `json:"threadID,omitempty"`
}
CreateResult represents the result of create method
func Create ¶
func Create(ctx context.Context, client api.CreateAndSendEmailAPI, input CreateInput) (*CreateResult, error)
Create adds an email as draft in DynamoDB
TODO: refactor this function
type Cursor ¶ added in v1.1.0
type Cursor struct {
QueryInfo QueryInfo `json:"queryInfo"`
LastEvaluatedKey LastEvaluatedKey `json:"lastEvaluatedKey"`
}
func (*Cursor) BindString ¶ added in v1.1.0
func (Cursor) MarshalJSON ¶ added in v1.1.0
func (*Cursor) UnmarshalJSON ¶ added in v1.1.0
type GSIIndex ¶
type GSIIndex struct {
MessageID string `dynamodbav:"MessageID"`
TypeYearMonth string `dynamodbav:"TypeYearMonth"`
DateTime string `dynamodbav:"DateTime"`
}
GSIIndex represents Global Secondary Index of an email
func (GSIIndex) ToTimeIndex ¶
ToTimeIndex returns TimeIndex
type GetResult ¶
type GetResult struct {
MessageID string `json:"messageID"`
OriginalMessageID string `json:"originalMessageID"`
Type string `json:"type"`
Subject string `json:"subject"`
From []string `json:"from"`
To []string `json:"to"`
Text string `json:"text"`
HTML string `json:"html"`
ReplyTo []string `json:"replyTo"`
InReplyTo string `json:"inReplyTo"`
References string `json:"references"` // space separated string
ThreadID string `json:"threadID,omitempty"`
IsThreadLatest bool `json:"isThreadLatest,omitempty"`
// Inbox email attributes
TimeReceived string `json:"timeReceived,omitempty"`
DateSent string `json:"dateSent,omitempty"`
Source string `json:"source,omitempty"`
Destination []string `json:"destination,omitempty"`
ReturnPath string `json:"returnPath,omitempty"`
Verdict *Verdict `json:"verdict,omitempty"`
Unread *bool `json:"unread,omitempty"`
// Draft email attributes
TimeUpdated string `json:"timeUpdated,omitempty"`
Cc []string `json:"cc,omitempty"`
Bcc []string `json:"bcc,omitempty"`
// Sent email attributes
TimeSent string `json:"timeSent,omitempty"`
// Attachment attributes, currently only support
Attachments *model.Files `json:"attachments,omitempty"`
Inlines *model.Files `json:"inlines,omitempty"`
OtherParts *model.Files `json:"otherParts,omitempty"`
}
GetResult represents the result of get method
func GetAndRead ¶ added in v1.6.0
Get returns the email and marks it as read
func ParseGetResult ¶ added in v1.6.0
func ParseGetResult(attributeValues map[string]dynamodbTypes.AttributeValue) (*GetResult, error)
type Input ¶ added in v1.10.0
type Input struct {
MessageID string `json:"messageID"`
Subject string `json:"subject"`
From []string `json:"from"`
To []string `json:"to"`
Cc []string `json:"cc"`
Bcc []string `json:"bcc"`
ReplyTo []string `json:"replyTo"`
InReplyTo string
References string
Text string `json:"text"`
HTML string `json:"html"`
ThreadID string `json:"threadID,omitempty"`
}
func (Input) GenerateAttributes ¶ added in v1.10.0
func (e Input) GenerateAttributes(typeYearMonth, dateTime string) map[string]dynamodbTypes.AttributeValue
GenerateAttributes generates DynamoDB AttributeValues
type LastEvaluatedKey ¶ added in v1.1.0
type LastEvaluatedKey map[string]dynamodbTypes.AttributeValue
func (*LastEvaluatedKey) Decode ¶ added in v1.3.0
func (k *LastEvaluatedKey) Decode(data []byte) error
func (LastEvaluatedKey) Encode ¶ added in v1.3.0
func (k LastEvaluatedKey) Encode() ([]byte, error)
type ListInput ¶ added in v1.1.0
type ListInput struct {
Type string `json:"type"`
Year string `json:"year"`
Month string `json:"month"`
Order string `json:"order"` // asc or desc (default)
ShowTrash string `json:"showTrash"` // 'include', 'exclude' or 'only' (default is 'exclude')
PageSize int32 `json:"pageSize"` // 0 means no limit, default is 100
NextCursor *Cursor `json:"nextCursor"`
}
ListInput represents the input of list method
type ListResult ¶
type ListResult struct {
Count int `json:"count"`
Items []Item `json:"items"`
NextCursor *Cursor `json:"nextCursor"`
HasMore bool `json:"hasMore"`
}
ListResult represents the result of list method
type OriginalMessageIDIndex ¶ added in v1.5.0
type RawEmailItem ¶ added in v1.3.0
type RawEmailItem struct {
GSIIndex
Subject string
From []string `json:"from"`
To []string `json:"to"`
Unread *bool `json:"unread,omitempty"`
ThreadID string `json:"threadID,omitempty"`
IsThreadLatest bool `json:"isThreadLatest,omitempty"`
}
func (RawEmailItem) ToEmailItem ¶ added in v1.3.0
func (raw RawEmailItem) ToEmailItem() (*Item, error)
type SaveInput ¶
type SaveInput struct {
Input
GenerateText string `json:"generateText"` // on, off, or auto (default)
Send bool `json:"send"` // send email immediately
}
SaveInput represents the input of save method
type SaveResult ¶
type SaveResult struct {
TimeIndex
Subject string `json:"subject"`
From []string `json:"from"`
To []string `json:"to"`
Cc []string `json:"cc"`
Bcc []string `json:"bcc"`
ReplyTo []string `json:"replyTo"`
Text string `json:"text"`
HTML string `json:"html"`
ThreadID string `json:"threadID,omitempty"`
}
SaveResult represents the result of save method
func Save ¶
func Save(ctx context.Context, client api.SaveAndSendEmailAPI, input SaveInput) (*SaveResult, error)
Save puts an email as draft in DynamoDB
TODO: refactor this function
type SendResult ¶ added in v1.1.1
type SendResult struct {
MessageID string
}
func Send ¶
func Send(ctx context.Context, client api.GetAndSendEmailAPI, messageID string) (*SendResult, error)
Send sends a draft email
type ThreadInfo ¶ added in v1.5.1
type TimeIndex ¶
type TimeIndex struct {
MessageID string `json:"messageID"`
Type string `json:"type"`
// TimeReceived is used by inbox emails
TimeReceived string `json:"timeReceived,omitempty"`
// TimeUpdated is used by draft emails
TimeUpdated string `json:"timeUpdated,omitempty"`
// TimeSent is used by sent emails
TimeSent string `json:"timeSent,omitempty"`
}
TimeIndex represents the index attributes of an email