Documentation
¶
Index ¶
- func BuildGmailLink(messageID string) string
- func GetFromAddress(from string) string
- func GetFromDomain(email string) string
- func GetTokenFromWeb(config *oauth2.Config) (*oauth2.Token, error)
- func LoadCredentials(credPath string) (*oauth2.Config, error)
- func LoadToken() (*oauth2.Token, error)
- func SaveToken(token *oauth2.Token) error
- func TokenExists() bool
- type Client
- func (c *Client) GetMessagesAfter(afterMessageID string, maxResults int64) ([]*gmail.Message, error)
- func (c *Client) GetRecentMessages(maxResults int64) ([]*gmail.Message, error)
- func (c *Client) GetRecentMessagesWithQuery(maxResults int64, searchQuery string) ([]*gmail.Message, error)
- func (c *Client) MarkAsRead(messageID string) error
- func (c *Client) RefreshTokenIfNeeded() error
- type EmailMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildGmailLink ¶
BuildGmailLink generates a stable Gmail permalink from a message ID The link uses #all/ to work regardless of which label/folder the email is in Example: BuildGmailLink("abc123") -> "https://mail.google.com/mail/u/0/#all/abc123"
func GetFromAddress ¶
GetFromAddress extracts just the email address from a "From" header Example: "John Doe <[email protected]>" -> "[email protected]"
func GetFromDomain ¶
GetFromDomain extracts the domain from an email address Example: "[email protected]" -> "example.com"
func GetTokenFromWeb ¶
GetTokenFromWeb starts the OAuth flow and returns a token
func LoadCredentials ¶
LoadCredentials reads the OAuth credentials from credentials.json
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Gmail API service with auto-refreshing tokens
func NewClient ¶
NewClient creates a new Gmail API client using the provided OAuth token The client automatically refreshes expired tokens and saves them to disk
func (*Client) GetMessagesAfter ¶
func (c *Client) GetMessagesAfter(afterMessageID string, maxResults int64) ([]*gmail.Message, error)
GetMessagesAfter fetches messages received after a specific message ID
func (*Client) GetRecentMessages ¶
GetRecentMessages fetches recent messages from the inbox with retry logic maxResults specifies the maximum number of messages to retrieve Defaults to searching only the inbox (in:inbox)
func (*Client) GetRecentMessagesWithQuery ¶
func (c *Client) GetRecentMessagesWithQuery(maxResults int64, searchQuery string) ([]*gmail.Message, error)
GetRecentMessagesWithQuery fetches recent messages with a custom Gmail search query maxResults specifies the maximum number of messages to retrieve searchQuery uses Gmail search syntax (e.g., "in:inbox", "-in:trash", "", etc.)
func (*Client) MarkAsRead ¶
MarkAsRead marks a message as read
func (*Client) RefreshTokenIfNeeded ¶
RefreshTokenIfNeeded manually refreshes the token if it's expired or about to expire
type EmailMessage ¶
EmailMessage represents a parsed email message
func ParseMessage ¶
func ParseMessage(msg *gmail.Message) *EmailMessage
ParseMessage extracts relevant fields from a Gmail API message