Skip to content

Commit 6a67cb7

Browse files
committed
Timestamp fix for event emission
1 parent a029644 commit 6a67cb7

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

components/frontapp/sources/common/base.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export default {
1919
_setLastTs(lastTs) {
2020
this.db.set("lastTs", lastTs);
2121
},
22+
_getItemTs(item) {
23+
return item.created_at * 1000;
24+
},
2225
async startEvent(maxResults = 0, filterFn = null) {
2326
const lastTs = this._getLastTs();
2427
const items = this.frontapp.paginate({

components/frontapp/sources/new-conversation-created/new-conversation-created.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ export default {
2323
_getEmit(conversation) {
2424
return {
2525
id: conversation.id,
26-
summary: `New conversation created: ${conversation.subject}`,
26+
summary: `New conversation: ${conversation.subject}`,
2727
ts: conversation.created_at * 1000,
2828
};
2929
},
3030
},
3131
hooks: {
3232
async deploy() {
33-
await this.startEvent(25, (item, lastTs) => item.created_at > lastTs);
33+
await this.startEvent(25, (item, lastTs) => this._getItemTs(item) > lastTs);
3434
},
3535
},
3636
async run() {
37-
await this.startEvent(0, (item, lastTs) => item.created_at > lastTs);
37+
await this.startEvent(0, (item, lastTs) => this._getItemTs(item) > lastTs);
3838
},
3939
sampleEmit,
4040
};

components/frontapp/sources/new-message-template-created/new-message-template-created.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ export default {
2323
_getEmit(template) {
2424
return {
2525
id: template.id,
26-
summary: `New message template created: ${template.name}`,
26+
summary: `New template: ${template.name}`,
2727
ts: template.created_at * 1000,
2828
};
2929
},
3030
},
3131
hooks: {
3232
async deploy() {
33-
await this.startEvent(25, (item, lastTs) => item.created_at > lastTs);
33+
await this.startEvent(25, (item, lastTs) => this._getItemTs(item) > lastTs);
3434
},
3535
},
3636
async run() {
37-
await this.startEvent(0, (item, lastTs) => item.created_at > lastTs);
37+
await this.startEvent(0, (item, lastTs) => this._getItemTs(item) > lastTs);
3838
},
3939
sampleEmit,
4040
};

0 commit comments

Comments
 (0)