Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit e8507f8

Browse files
author
Samuel Hassine
committed
[client] Catchup event IDs in state
1 parent c58f2fa commit e8507f8

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

pycti/connector/opencti_connector_helper.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,30 +307,19 @@ def run(self):
307307
)
308308

309309
for msg in messages:
310-
if msg.event == "heartbeat":
311-
logging.info("HEARTBEAT:" + str(msg))
310+
if msg.event == "heartbeat" or msg.event == "connected":
312311
continue
313-
elif msg.event == "connected":
314-
logging.info("CONNECTED:" + str(msg))
315312
elif msg.event == "catch":
316-
logging.info("Catchup done")
317-
else:
318-
event_id = msg.id
319-
if event_id is not None:
320-
date = datetime.datetime.fromtimestamp(
321-
round(int(event_id.split("-")[0]) / 1000)
322-
)
323-
logging.info(
324-
"Processing message (id: "
325-
+ event_id
326-
+ ", date: "
327-
+ str(date)
328-
+ ")"
329-
)
313+
if msg.id is not None:
330314
state = self.helper.get_state()
331-
state["connectorLastEventId"] = str(event_id)
315+
state["connectorLastEventId"] = str(msg.id)
332316
self.helper.set_state(state)
317+
else:
333318
self.callback(msg)
319+
if msg.id is not None:
320+
state = self.helper.get_state()
321+
state["connectorLastEventId"] = str(msg.id)
322+
self.helper.set_state(state)
334323

335324

336325
class OpenCTIConnectorHelper:

0 commit comments

Comments
 (0)