byeokim / gmailpush

Gmail API push notification handler for Node.js
MIT License
53 stars 7 forks source link

Get watchExpiration = null #9

Closed IRediTOTO closed 3 years ago

IRediTOTO commented 3 years ago

Hi I getting this, I don't understand why :( Can you give me an idea?

{"data":"[{\"emailAddress\":\"mailA@gmai.com\",\"prevHistoryId\":60039,\"watchExpiration\":null},{\"emailAddress\":\"mailA@gmai.com\",\"prevHistoryId\":60134,\"watchExpiration\":null},{\"emailAddress\":\"mailA@gmai.com\",\"prevHistoryId\":60143,\"watchExpiration\":null} // but this not, i dont understand why,{\"emailAddress\":\"mailB@gmai.com\",\"prevHistoryId\":6141093,\"watchExpiration\":1607275262534}]"} // this work fine

IRediTOTO commented 3 years ago

Error from here: ``` at Gmailpush._initialize (/app/node_modules/gmailpush/lib/gmailpush.js:114:33)

// Call watch() to extend watch expiration for 7 days
prevHistory.watchExpiration = await this._refreshWatch();
byeokim commented 3 years ago

What is content of gmailpush_history.json? Is that something like the following?

[
  {
    "emailAddress": "mailA@gmai.com",
    "prevHistoryId": 60039,
    "watchExpiration": null
  },
  {
    "emailAddress": "mailA@gmai.com",
    "prevHistoryId": 60134,
    "watchExpiration": null
  },
  {
    "emailAddress": "mailA@gmai.com",
    "prevHistoryId": 60143,
    "watchExpiration": null
  },
  {
    "emailAddress": "mailB@gmai.com",
    "prevHistoryId": 6141093,
    "watchExpiration": 1607275262534
  }
]

Or does it look like this?

{
  data: [
    {
      "emailAddress": "mailA@gmai.com",
      "prevHistoryId": 60039,
      "watchExpiration": null
    },
    {
      "emailAddress": "mailA@gmai.com",
      "prevHistoryId": 60134,
      "watchExpiration": null
    },
    {
      "emailAddress": "mailA@gmai.com",
      "prevHistoryId": 60143,
      "watchExpiration": null
    },
    {
      "emailAddress": "mailB@gmai.com",
      "prevHistoryId": 6141093,
      "watchExpiration": 1607275262534
    }
  ]
}
IRediTOTO commented 3 years ago

Like this: { data: [ { "emailAddress": "mailA@gmai.com", "prevHistoryId": 60039, "watchExpiration": null }, { "emailAddress": "mailA@gmai.com", "prevHistoryId": 60134, "watchExpiration": null }, { "emailAddress": "mailA@gmai.com", "prevHistoryId": 60143, "watchExpiration": null }, { "emailAddress": "mailB@gmai.com", "prevHistoryId": 6141093, "watchExpiration": 1607275262534 } ] }

But I fixed by use just one gmail... One email is ok. But too will throw this error canot set property "watchExpiration" of undefine

IRediTOTO commented 3 years ago

Now it fine, just like this {"data":"[{\"emailAddress\":\"Aemail@gmail.com\",\"prevHistoryId\":61582,\"watchExpiration\":1607312287554}]"}

byeokim commented 3 years ago

gmailpush_history.json should not have data key in it. Do you know why your gmailpush_history.json has data key?

IRediTOTO commented 3 years ago

Just checked, the data key gone now. I just copied so it have data key. I don't understand too. But I just use one email so it work fine :c