Skip to content

Commit 22f6cc6

Browse files
truncate timestamp in query
1 parent a325ef8 commit 22f6cc6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

components/gmail/sources/common/polling-messages.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ export default {
2929
constructQuery(lastDate) {
3030
const { q: query } = this;
3131
const after = !query?.includes("after:") && lastDate
32-
? `after:${lastDate / 1000}`
32+
? `after:${Math.trunc(lastDate / 1000)}`
3333
: "";
34-
return [
34+
const q = [
3535
after,
3636
query,
3737
].join(" ").trim();
38+
console.log(`Polling for new messages with query: ${q}`);
39+
return q;
3840
},
3941
async getMessageIds(max, lastDate = 0) {
40-
console.log("Polling for new messages...");
4142
const { messages } = await this.gmail.listMessages({
4243
q: this.constructQuery(lastDate),
4344
labelIds: this.getLabels(),
@@ -48,6 +49,7 @@ export default {
4849
async processMessageIds(messageIds, lastDate) {
4950
let maxDate = lastDate;
5051
const messages = this.gmail.getAllMessages(messageIds);
52+
console.log("Processing messages...");
5153
for await (const message of messages) {
5254
if (message.internalDate >= lastDate) {
5355
this.emitEvent(message);

components/gmail/sources/new-attachment-received/new-attachment-received.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ export default {
3636
? ""
3737
: "has:attachment";
3838
const after = !query?.includes("after:") && lastDate
39-
? `after:${lastDate / 1000}`
39+
? `after:${Math.trunc(lastDate / 1000)}`
4040
: "";
41-
return [
41+
const q = [
4242
hasAttachment,
4343
after,
4444
query,
4545
].join(" ").trim();
46+
console.log(`Polling for new messages with query: ${q}`);
47+
return q;
4648
},
4749
getLabels() {
4850
return this.labels;

0 commit comments

Comments
 (0)