thread

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v1.7.0

func Delete(ctx context.Context, client api.DeleteThreadAPI, messageID string) error

Delete deletes a trashed thread as well as its emails from DynamoDB and S3. It will return an error if the thread is not trashed.

func StoreEmail

func StoreEmail(ctx context.Context, client api.StoreEmailAPI, input *StoreEmailInput)

StoreEmail attempts to store the email. If error occurs, it will be logged and the function will return.

func StoreEmailWithExistingThread

func StoreEmailWithExistingThread(ctx context.Context, client api.TransactWriteItemsAPI, input *StoreEmailWithExistingThreadInput) error

StoreEmailWithExistingThread stores the email and updates the thread.

func StoreEmailWithNewThread

func StoreEmailWithNewThread(ctx context.Context, client api.TransactWriteItemsAPI, input *StoreEmailWithNewThreadInput) error

StoreEmailWithNewThread stores the email, creates a new thread, and add ThreadID to previous email

func Trash added in v1.7.0

func Trash(ctx context.Context, client api.UpdateItemAPI, threadID string) error

func Untrash added in v1.7.0

func Untrash(ctx context.Context, client api.UpdateItemAPI, messageID string) error

Untrash marks an trashed email as not trashed

Types

type DetermineThreadInput

type DetermineThreadInput struct {
	InReplyTo  string
	References string
}

type DetermineThreadOutput

type DetermineThreadOutput struct {
	ThreadID          string
	Exists            bool   // If true, the email belongs to an existing thread
	PreviousMessageID string // If Exists is true, the messageID of the last email in the thread

	ShouldCreate    bool   // If true, a new thread should be created
	CreatingEmailID string // If ShouldCreate is true, the messageID of the first email in the thread
	CreatingSubject string // If ShouldCreate is true, the subject of the first email in the thread
	CreatingTime    string // If ShouldCreate is true, the time the first email is received
}

func DetermineThread

func DetermineThread(ctx context.Context, client api.QueryAndGetItemAPI, input *DetermineThreadInput) (*DetermineThreadOutput, error)

DetermineThread determines which thread an incoming email belongs to. If a thread already exists, the ThreadID is returned and Exists is true. If a thread does not exist and a new thread should be created, the ThreadID is randomly generated and ShouldCreate is true.

type StoreEmailInput

type StoreEmailInput struct {
	InReplyTo    string
	References   string
	Item         map[string]dynamodbTypes.AttributeValue
	TimeReceived string // RFC3339
}

type StoreEmailWithExistingThreadInput

type StoreEmailWithExistingThreadInput struct {
	ThreadID          string
	Email             map[string]dynamodbTypes.AttributeValue
	TimeReceived      string
	PreviousMessageID string
}

type StoreEmailWithNewThreadInput

type StoreEmailWithNewThreadInput struct {
	ThreadID        string
	Email           map[string]dynamodbTypes.AttributeValue
	TimeReceived    string
	CreatingEmailID string
	CreatingSubject string
	CreatingTime    string
}

type Thread

type Thread struct {
	MessageID   string   `json:"messageID"`
	Type        string   `json:"type"`    // always "thread"
	Subject     string   `json:"subject"` // The subject of the first email in the thread
	EmailIDs    []string `json:"emailIDs"`
	DraftID     string   `json:"draftID,omitempty"`
	TimeUpdated string   `json:"timeUpdated"`           // The time the last email is received or sent
	TrashedTime *string  `json:"trashedTime,omitempty"` // Time in RFC3339 format

	Emails []email.GetResult `json:"emails,omitempty"`
	Draft  *email.GetResult  `json:"draft,omitempty"`
}

func GetThread

func GetThread(ctx context.Context, client api.GetItemAPI, messageID string) (*Thread, error)

func GetThreadWithEmails

func GetThreadWithEmails(ctx context.Context, client api.GetThreadWithEmailsAPI, messageID string) (*Thread, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL