gmailutils

package
v0.0.0-...-2d7094a Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package gmailutils provides helpers for Gmail API.

Index

Constants

View Source
const Instructions = `` /* 301-byte string literal not displayed */

Instructions are user manual for OAuth app configuration from Gmail.

Variables

This section is empty.

Functions

func FetchConcurent

func FetchConcurent(ctx context.Context, srv *gmail.Service, user, query string, concurentReq int) ([]*gmail.Message, error)

FetchConcurent fetches matching messages for a given query in paralle from the Gmail. It is blocking, but doing N concurrent fetche requests. TODO(bzz): make it a method on the struct, that holds srv instance.

func FetchLabels

func FetchLabels(ctx context.Context, client *http.Client) (
	*gmail.ListLabelsResponse, error)

FetchLabels fetches the list of labels, as returned by Gmail using authorized http Client.

func FormatAsID

func FormatAsID(label string) string

FormatAsID formats human-readable lable as ID, consumable by Gmail API.

func MessageTextBody

func MessageTextBody(payload *gmail.MessagePart) ([]byte, error)

MessageTextBody returns the text (if any) of a given message ID

func ModifyMsgsDelLabel

func ModifyMsgsDelLabel(srv *gmail.Service, user string, messages []*gmail.Message, label string)

ModifyMsgsDelLabel batch-deletes a label from all the given messages. TODO(bzz): move user to a const in this package

func NewClient

func NewClient(needWriteAccess bool) *http.Client

NewClient a client configured with OAuth using 'credentials.json' and a 'token.json'.

func NormalizeAndSplit

func NormalizeAndSplit(subj string) []string

NormalizeAndSplit normalizes subj format and split it to type/source.

func PrintAllLabels

func PrintAllLabels(srv *gmail.Service, user string) []*gmail.Label

PrintAllLabels prints all labels for a given user.

func ReadLblFixturesJSON

func ReadLblFixturesJSON(name string) []*gmail.Label

ReadLblFixturesJSON reads Gmail labels from a given JSON file.

func ReadMsgFixturesJSON

func ReadMsgFixturesJSON(name string) []*gmail.Message

ReadMsgFixturesJSON reads Gmail messages from a given JSON file.

func Subject

func Subject(m *gmail.MessagePart) string

Subject returns the Subject header of a message

Types

This section is empty.

Directories

Path Synopsis
Package token provides utilities for caching Gmail auth token.
Package token provides utilities for caching Gmail auth token.

Jump to

Keyboard shortcuts

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