gdrive2slack

package
v0.0.0-...-43e2668 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSlackAttachment

func CreateSlackAttachment(change *drive.ChangeItem) *slack.Attachment

func CreateSlackMessage

func CreateSlackMessage(subscription *Subscription, userState *UserState, folders *drive.Folders, version string) *slack.Message

func CreateSlackUnknownChannelMessage

func CreateSlackUnknownChannelMessage(subscription *Subscription, redirectUri string, source *slack.Message) *slack.Message

func CreateSlackWelcomeMessage

func CreateSlackWelcomeMessage(channel string, redirectUri string, sUserInfo *slack.UserInfo, version string) *slack.Message

func EventLoop

func EventLoop(env *Environment)

func ServeHttp

func ServeHttp(env *Environment)

Types

type Configuration

type Configuration struct {
	BindAddress      string                     `json:"bindAddress"`
	Workers          int                        `json:"workers"`
	Interval         int                        `json:"interval"`
	GoogleTrackingId string                     `json:"googleTrackingId"`
	Google           *google.OauthConfiguration `json:"google"`
	Slack            *slack.OauthConfiguration  `json:"slack"`
	Mailchimp        *mailchimp.Configuration   `json:"mailchimp"`
}

func LoadConfiguration

func LoadConfiguration(filename string) (*Configuration, error)

type Environment

type Environment struct {
	Version         string
	Configuration   *Configuration
	Logger          *Logger
	HttpClient      *http.Client
	RegisterChannel chan *SubscriptionAndAccessToken
	SignalsChannel  chan os.Signal
}

func NewEnvironment

func NewEnvironment(version string, conf *Configuration, logger *Logger) *Environment

type ErrResponse

type ErrResponse struct {
	Error string `json:"error"`
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(out io.Writer, prefix string, flag int) *Logger

func (*Logger) Error

func (self *Logger) Error(format string, v ...interface{})

func (*Logger) Info

func (self *Logger) Info(format string, v ...interface{})

func (*Logger) Warning

func (self *Logger) Warning(format string, v ...interface{})

type Request

type Request struct {
	GoogleCode string   `json:"g"`
	SlackCode  string   `json:"s"`
	Channel    string   `json:"c"`
	FolderIds  []string `json:"fids"`
	FolderName string   `json:"fn"`
}

type Subscription

type Subscription struct {
	Channel                    string             `json:"channel"`
	SlackAccessToken           string             `json:"slack_access_token"`
	GoogleRefreshToken         string             `json:"google_refresh_token"`
	GoogleUserInfo             *userinfo.UserInfo `json:"guser"`
	SlackUserInfo              *slack.UserInfo    `json:"suser"`
	GoogleInterestingFolderIds []string           `json:"google_interesting_folder_ids"`
}

type SubscriptionAndAccessToken

type SubscriptionAndAccessToken struct {
	Subscription      *Subscription
	GoogleAccessToken string
}

type Subscriptions

type Subscriptions struct {
	Source string
	Info   map[string]*Subscription
	States map[string]*UserState
}

func LoadSubscriptions

func LoadSubscriptions(filename string) (*Subscriptions, error)

func (*Subscriptions) Add

func (subscriptions *Subscriptions) Add(subscription *Subscription, googleAccessToken string)

func (*Subscriptions) Contains

func (subscriptions *Subscriptions) Contains(email string) bool

func (*Subscriptions) HandleFailure

func (subscriptions *Subscriptions) HandleFailure(email string) (*Subscription, string, bool)

func (*Subscriptions) HandleSuccess

func (subscriptions *Subscriptions) HandleSuccess(email string)

type UserState

type UserState struct {
	Gdrive            *drive.State
	GoogleAccessToken string
	FailingSince      *time.Time
}

Jump to

Keyboard shortcuts

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