98
func New(accountId uint) *GmailPlugin {
99
reportedIds, err := idsFromPersist(accountId)
101
log.Print("gmail plugin ", accountId, ": cannot load previous state from storage: ", err)
103
log.Print("gmail plugin ", accountId, ": last state loaded from storage")
105
return &GmailPlugin{reportedIds: reportedIds, accountId: accountId}
97
func New() *GmailPlugin {
98
return &GmailPlugin{ accountId: 0 }
108
101
func (p *GmailPlugin) ApplicationId() plugins.ApplicationId {
109
102
return plugins.ApplicationId(APP_ID)
112
func (p *GmailPlugin) Poll(authData *accounts.AuthData) ([]*plugins.PushMessageBatch, error) {
105
func (p *GmailPlugin) Poll(authData *plugins.AuthData) ([]*plugins.PushMessageBatch, error) {
113
106
// This envvar check is to ease testing.
114
107
if token := os.Getenv("ACCOUNT_POLLD_TOKEN_GMAIL"); token != "" {
115
108
authData.AccessToken = token
111
if p.accountId != authData.AccountId {
112
p.accountId = authData.AccountId
113
reportedIds, err := idsFromPersist(p.accountId)
115
log.Print("gmail plugin ", p.accountId, ": cannot load previous state from storage: ", err)
117
log.Print("gmail plugin ", p.accountId, ": last state loaded from storage")
119
p.reportedIds = reportedIds
118
122
resp, err := p.requestMessageList(authData.AccessToken)