Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteCachedScopeToken(scope *ScopeProfile)
- func GetMessageBody(msg *gm.Message) []string
- func MessageHasBody(msg *gm.Message) bool
- func MessageIdsByThread(msgs []*gm.Message) map[string][]*MessageId
- func MessageMeetsDetailLevel(msg *gm.Message, detail MessageDetailLevel) bool
- func MessagesByThread(msgs []*gm.Message) map[string][]*gm.Message
- func MessagesLatestFirst(msgs []*gm.Message) []*gm.Message
- func NewGmailClient(scope *ScopeProfile) *gmail.Service
- type AccountHelper
- type Cache
- type EmailAddress
- type Headers
- type Label
- type MessageDetailLevel
- type MessageFormat
- type MessageId
- type MsgHelper
- func (h *MsgHelper) ApplyLabels(msgs []*gm.Message, labelsToAdd []Label, labelsToRemove []Label) error
- func (h *MsgHelper) ApplyLabelsToThreads(threads []*gm.Thread, labelNames []string) error
- func (h *MsgHelper) BatchModifyMessages(msgs []*gm.Message, modReq *gm.BatchModifyMessagesRequest) error
- func (h *MsgHelper) GetMessage(id string, detail MessageDetailLevel) (*gm.Message, error)
- func (h *MsgHelper) GetThread(id string, detail MessageDetailLevel) (*gm.Thread, error)
- func (h *MsgHelper) LabelIdForLabel(l *Label) string
- func (h *MsgHelper) LabelIdFromName(label string) string
- func (h *MsgHelper) LabelIdsForLabels(labels []Label) []string
- func (h *MsgHelper) LabelName(lblId string) string
- func (h *MsgHelper) LabelNames(ids []string) []string
- func (h *MsgHelper) LoadMessages(msgs []*gm.Message, detail MessageDetailLevel) ([]*gm.Message, error)
- func (h *MsgHelper) MessageLabelNames(m *gm.Message) []string
- func (h *MsgHelper) QueryMessages(query string, inboxOnly bool, unreadOnly bool, maxMsgs int64, ...) ([]*gm.Message, error)
- func (h *MsgHelper) QueryThreads(query string, inboxOnly bool, unreadOnly bool, maxEntries int64, ...) ([]*gm.Thread, error)
- func (h *MsgHelper) ThreadIsLoaded(id string) bool
- func (h *MsgHelper) ThreadLabelNames(threadId string) ([]string, error)
- type ScopeProfile
Constants ¶
const ( CredentialsDirName = ".credentials" ClientSecretFileName = "client_secret.json" // Just use the user that we have credentials for DefaultUser = "me" )
const (
MaxBatchModifySize = 500
)
Variables ¶
var FiltersScope = &ScopeProfile{ Scopes: []string{gmail.GmailMetadataScope, gmail.GmailSettingsBasicScope}, CredFile: "gmailcli_filters.json", }
var InboxLabel = NewLabelWithId("INBOX")
Constant Labels
var LabelsScope = &ScopeProfile{ Scopes: []string{gmail.GmailReadonlyScope, gmail.GmailMetadataScope}, CredFile: "gmailcli_labels.json", }
var MaxConcurrentRequests = 80
Determined heuristically from testing We should avoid making more than this many rquests in parallel, else the gmail service will yield errors. The API does not publicly say what the limit is at the moment.
var ModifyScope = &ScopeProfile{ Scopes: []string{gmail.GmailModifyScope}, CredFile: "gmailcli_modify.json", }
var ReadScope = &ScopeProfile{ Scopes: []string{gmail.GmailReadonlyScope}, CredFile: "gmailcli_read.json", }
Scope docs: https://godoc.org/google.golang.org/api/gmail/v1 If modifying these scopes, delete your previously saved credentials at ~/.credentials/...
var SpecialLabelNames = []string{
"UNREAD",
"CATEGORY_PERSONAL",
"CATEGORY_SOCIAL",
"CATEGORY_PROMOTIONS",
"CATEGORY_UPDATES",
"CATEGORY_FORUMS",
"IMPORTANT",
"INBOX",
}
var TrashLabel = NewLabelWithId("TRASH")
Functions ¶
func DeleteCachedScopeToken ¶
func DeleteCachedScopeToken(scope *ScopeProfile)
func GetMessageBody ¶
Decodes the messages' body text, putting each part as a separate entry in the returned slice. Will be at least size 1
func MessageHasBody ¶
func MessageMeetsDetailLevel ¶
func MessageMeetsDetailLevel(msg *gm.Message, detail MessageDetailLevel) bool
func NewGmailClient ¶
func NewGmailClient(scope *ScopeProfile) *gmail.Service
Types ¶
type AccountHelper ¶
type AccountHelper struct { User string // contains filtered or unexported fields }
func NewAccountHelper ¶
func NewAccountHelper(user string, srv *gm.Service) *AccountHelper
func (*AccountHelper) GetEmailAddress ¶
func (h *AccountHelper) GetEmailAddress() (string, error)
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) UpdateMsgs ¶
type EmailAddress ¶
func GetEmailsInField ¶
func GetEmailsInField(fromHeaderVal string) []EmailAddress
type Headers ¶
type Headers struct { Subject string From EmailAddress To []EmailAddress Cc []EmailAddress }
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
func LabelsFromLabelNames ¶
func NewLabelWithId ¶
func NewLabelWithName ¶
type MessageDetailLevel ¶
type MessageDetailLevel int
const ( IdsOnly MessageDetailLevel = iota LabelsOnly LabelsAndPayload )
func MoreDetailedLevel ¶
func MoreDetailedLevel(a, b MessageDetailLevel) MessageDetailLevel
func (MessageDetailLevel) Format ¶
func (dl MessageDetailLevel) Format() MessageFormat
type MessageFormat ¶
type MessageFormat string
const ( // Only the Raw. Payload will be nil MessageFormatRaw MessageFormat = "raw" )
Format values
func (MessageFormat) ToString ¶
func (f MessageFormat) ToString() string
type MessageId ¶
type MessageId struct {
Id string
}
A wrapper for a message Id that can be passed by reference. This helps save a little space, and reduces confusion about what contents a message contains when returned from certain functions.
type MsgHelper ¶
type MsgHelper struct { User string // contains filtered or unexported fields }
func (*MsgHelper) ApplyLabels ¶
func (*MsgHelper) ApplyLabelsToThreads ¶
func (*MsgHelper) BatchModifyMessages ¶
func (*MsgHelper) GetMessage ¶
func (*MsgHelper) LabelIdForLabel ¶
func (*MsgHelper) LabelIdFromName ¶
func (*MsgHelper) LabelIdsForLabels ¶
If labels is nil or empty, returns nil
func (*MsgHelper) LabelNames ¶
func (*MsgHelper) LoadMessages ¶
func (*MsgHelper) QueryMessages ¶
func (h *MsgHelper) QueryMessages( query string, inboxOnly bool, unreadOnly bool, maxMsgs int64, detailLevel MessageDetailLevel) ([]*gm.Message, error)
Query the server for messages. * maxMsgs: a value greater than 0 to apply a max
func (*MsgHelper) QueryThreads ¶
func (*MsgHelper) ThreadIsLoaded ¶
type ScopeProfile ¶
func (*ScopeProfile) ScopesString ¶
func (s *ScopeProfile) ScopesString() string