Make seen_ts a datetime, and rename to seen_at in onX methods
- onMessageSeen - onMarkedSeen
This commit is contained in:
@@ -2410,14 +2410,14 @@ class Client:
|
|||||||
# Message seen
|
# Message seen
|
||||||
elif delta_class == "ReadReceipt":
|
elif delta_class == "ReadReceipt":
|
||||||
seen_by = str(delta.get("actorFbId") or delta["threadKey"]["otherUserFbId"])
|
seen_by = str(delta.get("actorFbId") or delta["threadKey"]["otherUserFbId"])
|
||||||
seen_ts = int(delta["actionTimestampMs"])
|
seen_at = _util.millis_to_datetime(int(delta["actionTimestampMs"]))
|
||||||
delivered_ts = int(delta["watermarkTimestampMs"])
|
delivered_ts = int(delta["watermarkTimestampMs"])
|
||||||
thread_id, thread_type = getThreadIdAndThreadType(delta)
|
thread_id, thread_type = getThreadIdAndThreadType(delta)
|
||||||
self.onMessageSeen(
|
self.onMessageSeen(
|
||||||
seen_by=seen_by,
|
seen_by=seen_by,
|
||||||
thread_id=thread_id,
|
thread_id=thread_id,
|
||||||
thread_type=thread_type,
|
thread_type=thread_type,
|
||||||
seen_ts=seen_ts,
|
seen_at=seen_at,
|
||||||
ts=delivered_ts,
|
ts=delivered_ts,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
msg=m,
|
msg=m,
|
||||||
@@ -2425,8 +2425,8 @@ class Client:
|
|||||||
|
|
||||||
# Messages marked as seen
|
# Messages marked as seen
|
||||||
elif delta_class == "MarkRead":
|
elif delta_class == "MarkRead":
|
||||||
seen_ts = int(
|
seen_at = _util.millis_to_datetime(
|
||||||
delta.get("actionTimestampMs") or delta.get("actionTimestamp")
|
int(delta.get("actionTimestampMs") or delta.get("actionTimestamp"))
|
||||||
)
|
)
|
||||||
delivered_ts = int(
|
delivered_ts = int(
|
||||||
delta.get("watermarkTimestampMs") or delta.get("watermarkTimestamp")
|
delta.get("watermarkTimestampMs") or delta.get("watermarkTimestamp")
|
||||||
@@ -2441,7 +2441,7 @@ class Client:
|
|||||||
|
|
||||||
# thread_id, thread_type = getThreadIdAndThreadType(delta)
|
# thread_id, thread_type = getThreadIdAndThreadType(delta)
|
||||||
self.onMarkedSeen(
|
self.onMarkedSeen(
|
||||||
threads=threads, seen_ts=seen_ts, ts=delivered_ts, metadata=delta, msg=m
|
threads=threads, seen_at=seen_at, ts=delivered_ts, metadata=delta, msg=m
|
||||||
)
|
)
|
||||||
|
|
||||||
# Game played
|
# Game played
|
||||||
@@ -3231,7 +3231,7 @@ class Client:
|
|||||||
seen_by=None,
|
seen_by=None,
|
||||||
thread_id=None,
|
thread_id=None,
|
||||||
thread_type=ThreadType.USER,
|
thread_type=ThreadType.USER,
|
||||||
seen_ts=None,
|
seen_at=None,
|
||||||
ts=None,
|
ts=None,
|
||||||
metadata=None,
|
metadata=None,
|
||||||
msg=None,
|
msg=None,
|
||||||
@@ -3242,14 +3242,14 @@ class Client:
|
|||||||
seen_by: The ID of the person who marked the message as seen
|
seen_by: The ID of the person who marked the message as seen
|
||||||
thread_id: Thread ID that the action was sent to. See :ref:`intro_threads`
|
thread_id: Thread ID that the action was sent to. See :ref:`intro_threads`
|
||||||
thread_type (ThreadType): Type of thread that the action was sent to. See :ref:`intro_threads`
|
thread_type (ThreadType): Type of thread that the action was sent to. See :ref:`intro_threads`
|
||||||
seen_ts: A timestamp of when the person saw the message
|
seen_at (datetime.datetime): When the person saw the message
|
||||||
ts: A timestamp of the action
|
ts: A timestamp of the action
|
||||||
metadata: Extra metadata about the action
|
metadata: Extra metadata about the action
|
||||||
msg: A full set of the data received
|
msg: A full set of the data received
|
||||||
"""
|
"""
|
||||||
log.info(
|
log.info(
|
||||||
"Messages seen by {} in {} ({}) at {}s".format(
|
"Messages seen by {} in {} ({}) at {}".format(
|
||||||
seen_by, thread_id, thread_type.name, seen_ts / 1000
|
seen_by, thread_id, thread_type.name, seen_at
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -3281,21 +3281,21 @@ class Client:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def onMarkedSeen(
|
def onMarkedSeen(
|
||||||
self, threads=None, seen_ts=None, ts=None, metadata=None, msg=None
|
self, threads=None, seen_at=None, ts=None, metadata=None, msg=None
|
||||||
):
|
):
|
||||||
"""Called when the client is listening, and the client has successfully marked threads as seen.
|
"""Called when the client is listening, and the client has successfully marked threads as seen.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
threads: The threads that were marked
|
threads: The threads that were marked
|
||||||
author_id: The ID of the person who changed the emoji
|
author_id: The ID of the person who changed the emoji
|
||||||
seen_ts: A timestamp of when the threads were seen
|
seen_at (datetime.datetime): When the threads were seen
|
||||||
ts: A timestamp of the action
|
ts: A timestamp of the action
|
||||||
metadata: Extra metadata about the action
|
metadata: Extra metadata about the action
|
||||||
msg: A full set of the data received
|
msg: A full set of the data received
|
||||||
"""
|
"""
|
||||||
log.info(
|
log.info(
|
||||||
"Marked messages as seen in threads {} at {}s".format(
|
"Marked messages as seen in threads {} at {}".format(
|
||||||
[(x[0], x[1].name) for x in threads], seen_ts / 1000
|
[(x[0], x[1].name) for x in threads], seen_at
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user