Skip to content

Commit 78dde35

Browse files
committed
Added last_message_timestamp_ago for /conversations
1 parent c06f4d0 commit 78dde35

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

backend/PyMatcha/routes/api/messages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from PyMatcha.utils.errors import NotFoundError
3131
from PyMatcha.utils.success import Success
3232
from PyMatcha.utils.success import SuccessOutput
33+
from timeago import format as timeago_format
3334

3435

3536
REQUIRED_KEYS_NEW_MESSAGE = {"to_uid": str, "content": str}
@@ -44,6 +45,7 @@ def get_opened_conversations():
4445
returned_list = [
4546
{
4647
"last_message_timestamp": c.timestamp,
48+
"last_message_timestamp_ago": timeago_format(c.timestamp, datetime.datetime.utcnow()),
4749
"last_message_content": c.content,
4850
"is_unseen": True if not c.is_seen and c.to_id == current_user.id else False,
4951
"with_user": get_user(c.to_id if c.to_id != current_user.id else c.from_id).to_dict(),

0 commit comments

Comments
 (0)