~online-accounts/account-polld-plugins-go/trunk

« back to all changes in this revision

Viewing changes to plugins/dekko/dekko.go

  • Committer: Alberto Mardegan
  • Date: 2016-08-30 09:30:59 UTC
  • Revision ID: alberto.mardegan@canonical.com-20160830093059-3dkvisty1xjmz6cv
Update all plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
        "log"
32
32
 
33
 
        "launchpad.net/account-polld/accounts"
34
33
        "launchpad.net/account-polld/gettext"
35
34
        "launchpad.net/account-polld/plugins"
36
35
        "launchpad.net/account-polld/qtcontact"
95
94
        return nil
96
95
}
97
96
 
98
 
func New(accountId uint) *GmailPlugin {
99
 
        reportedIds, err := idsFromPersist(accountId)
100
 
        if err != nil {
101
 
                log.Print("gmail plugin ", accountId, ": cannot load previous state from storage: ", err)
102
 
        } else {
103
 
                log.Print("gmail plugin ", accountId, ": last state loaded from storage")
104
 
        }
105
 
        return &GmailPlugin{reportedIds: reportedIds, accountId: accountId}
 
97
func New() *GmailPlugin {
 
98
        return &GmailPlugin{ accountId: 0 }
106
99
}
107
100
 
108
101
func (p *GmailPlugin) ApplicationId() plugins.ApplicationId {
109
102
        return plugins.ApplicationId(APP_ID)
110
103
}
111
104
 
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
116
109
        }
117
110
 
 
111
        if p.accountId != authData.AccountId {
 
112
                p.accountId = authData.AccountId
 
113
                reportedIds, err := idsFromPersist(p.accountId)
 
114
                if err != nil {
 
115
                        log.Print("gmail plugin ", p.accountId, ": cannot load previous state from storage: ", err)
 
116
                } else {
 
117
                        log.Print("gmail plugin ", p.accountId, ": last state loaded from storage")
 
118
                }
 
119
                p.reportedIds = reportedIds
 
120
        }
 
121
 
118
122
        resp, err := p.requestMessageList(authData.AccessToken)
119
123
        if err != nil {
120
124
                return nil, err